Ios &引用;“文本”;不赞成
我正准备将iOS 6 iPhone应用程序更新为iOS 8。此代码的第二行生成错误消息(“文本”已弃用。第一行在iOS 3.0中弃用)。语法错误在我的应用程序中已经存在多年,没有引起任何问题,但我想我会在完成iOS 8版本之前清除所有错误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
- (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
属性已被弃用!文档会告诉你在它的位置使用什么。谢谢你的帮助。我最初试过你的建议,但没有多加一个括号。