-4

iOS 6 の iPhone アプリを iOS8 にアップデートする準備をしています。このコードの 2 行目は、エラー メッセージを生成します ("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);

}
4

2 に答える 2

0

[[tableView cellForRowAtIndexPath:indexPath] text]に表示されるテキストを取得するためにを使用する代わりにUITableViewCell、これを試してください:

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

UITableViewCell のドキュメントからの参照。

セル構造によってはdetailTextLabel、それも使用している場合は、見ることも役立つ場合があります。

于 2014-07-17T18:45:23.097 に答える
0

デフォルトでは本文用と詳細テキスト用のUITableViewCell2 つがあるため、このコードを使用できます。したがって、メイン ラベルのbyのテキストにアクセスできます。labels textLabeldetailTextLabelUITableViewCelltextLabel.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 に答える