1. ホーム
  2. ios

[解決済み] UITableViewの選択されたインデックスを取得する

2022-12-06 15:17:02

質問

の選択インデックスを作りたい。 UITableView . 以下のようなコードを書きました。

NSIndexPath *index = [NSIndexPath indexPathForRow:1 inSection:0];
[tableView scrollToRowAtIndexPath:index 
                 atScrollPosition:UITableViewScrollPositionTop 
                         animated:YES];

これは常に1番目の項目で動作します。私は、選択されたインデックスを indexPathForRow.

助けてください。 ありがとうございます。

どのように解決するのですか?

NSIndexPath *selectedIndexPath = [tableView indexPathForSelectedRow];