-4

我正准备将 iOS 6 iPhone 应用程序更新到 iOS8。此代码的第二行产生一条错误消息(“文本”已弃用。在 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);

}
4

2 回答 2

0

而不是[[tableView cellForRowAtIndexPath:indexPath] text]用来获取显示在你的文本UITableViewCell,试试这个:

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

来自UITableViewCell 文档的参考。

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

于 2014-07-17T18:45:23.097 回答
0

您可以使用此代码,因为默认情况下UITableViewCell有两个labels textLabel用于主文本和detailTextLabel详细文本。因此您可以访问主标签UITableViewCell的文本textLabel.text

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

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

}
于 2014-07-17T18:45:35.370 回答