2010-10-26 63 views
0

我得到错误,而使用UITableView作为'setText:'已弃用行cell.text = cellvalue 请任何人都可以如何解决这个问题?我得到错误,而使用UITableView作为'setText:'已弃用

- (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; 
} 

回答

3

cell.textLabel.text = @"Value"

+0

谢谢...它的工作.. – Cintu 2010-10-26 14:01:37

+0

omg我很愚蠢,我一直把cell.textLabel就是这样,但我忘了把.text放在最后,非常感谢你! – PatrickGamboa 2011-04-04 16:19:47

0

由于苹果添加了字幕样式表视图细胞,你需要使用:

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

代替。

+0

非常感谢...它的工作... – Cintu 2010-10-26 14:01:58

+0

如果您要使用字幕,请将initWithFrame:CGRectZero更改为initWithStyle:UITableViewCellStyleSubtitle。使用[cell.detailTextLabel setText:@“String”]设置字幕文本; – 2010-10-26 14:04:26

+0

真的有效... – Cintu 2010-10-26 14:09:59

相关问题