Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios &引用;“文本”;不赞成_Ios_Objective C_Uitableview_Deprecation Warning - Fatal编程技术网

Ios &引用;“文本”;不赞成

Ios &引用;“文本”;不赞成,ios,objective-c,uitableview,deprecation-warning,Ios,Objective C,Uitableview,Deprecation Warning,我正准备将iOS 6 iPhone应用程序更新为iOS 8。此代码的第二行生成错误消息(“文本”已弃用。第一行在iOS 3.0中弃用)。语法错误在我的应用程序中已经存在多年,没有引起任何问题,但我想我会在完成iOS 8版本之前清除所有错误 - (void)tableView:(UITableView *)tv1 didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [appDelegate muniClicked:[[tableView

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

}

不要使用
[[tableView cellForRowAtIndexPath:indexPath]文本]
获取显示在
UITableViewCell
中的文本,请尝试以下操作:

[[[tableView cellForRowAtIndexPath:indexPath] textLabel] text]
参考资料来源于


根据您的单元格结构,查看
detailtextlab
也可能有用,如果您也在使用它。

您可以使用此代码,默认情况下
UITableViewCell
有两个
标签
textlab
用于主文本,而
detailtextlab
用于详细文本。因此,您可以通过
textlab.text
访问
UITableViewCell
的文本

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

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

}

你的问题到底是什么?你看过
UITableViewCell
的文档了吗?自iOS 3.0以来,
text
属性已被弃用!文档会告诉你在它的位置使用什么。谢谢你的帮助。我最初试过你的建议,但没有多加一个括号。