"文本"已弃用

时间:2014-07-17 18:39:44

标签: ios objective-c uitableview deprecation-warning

我准备将iOS 6 iPhone应用更新到iOS8。此代码的第二行产生错误消息(" text"不推荐使用。首先在iOS 3.0中弃用)。语法错误已经在我的应用程序中存在多年没有引起问题,但我想我会在完成iOS 8版本之前清理任何错误。

- (void)tableView:(UITableView *)tv1 didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    [appDelegate muniClicked:[[tableView cellForRowAtIndexPath:indexPath] text]];
    NSLog(@"cell clicked {%d, %d}}", indexPath.row, indexPath.section);

}

2 个答案:

答案 0 :(得分:0)

不要使用[[tableView cellForRowAtIndexPath:indexPath] text]来显示UITableViewCell中显示的文字,请尝试以下操作:

[[[tableView cellForRowAtIndexPath:indexPath] textLabel] text]

来自UITableViewCell documentation的参考。

根据您的细胞结构,如果您正在使用它,那么查看detailTextLabel也可能很有用。

答案 1 :(得分:0)

您可以将此代码视为默认UITableViewCell,主文本有两个labels textLabel,详细文本有detailTextLabel。因此,您可以访问{的文字{1}} UITableViewCell为主标签

textLabel.text