使用UITableView时出现错误,因为'setText:'已被弃用

时间:2010-10-26 13:52:39

标签: iphone objective-c

使用UITableView时出现错误,因为'setText:'在行cell.text = cellvalue中已弃用 请有人可以解决这个问题吗?

- (UITableViewCell *)tableView:(UITableView *)atable cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [atable dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }
    NSString *cellValue = [listOfItems objectAtIndex:indexPath.row];

    cell.text = cellValue; //Error 'setText:' is deprecated 

    return cell;
}

2 个答案:

答案 0 :(得分:3)

cell.textLabel.text = @"Value"

答案 1 :(得分:0)

由于Apple将“字幕”样式添加到表格视图单元格,因此您需要使用:

[cell.textLabel setText:@"String"];

代替。

相关问题