基本的に、配列のインデックスをNSIntegerに格納しています。NSIndexpathとして必要になりました。再利用できるように、NSIntegerをNSIndexpathに変換する方法を見つけて見つけるのに苦労しています。
39289 次
4 に答える
90
intの場合index
:
NSIndexPath *path = [NSIndexPath indexPathWithIndex:index];
参照に従って指すようにノード0にアイテムのインデックスを作成します。
でindexPathを使用するにはUITableView
、より適切な方法は次のとおりです。
NSIndexPath *path = [NSIndexPath indexPathForRow:row inSection:section];
于 2011-06-23T13:27:18.177 に答える
8
のが必要な場合はNSIndexPath
、UITableView
indexPathForRow:inSection:
(参照)を使用できます。テーブルビューに渡されるインデックスパスには、セクションと行を指定する2つのインデックスが含まれている必要があります。で作成されたインデックスパスindexPathWithIndex:
には1つのインデックスのみが含まれ、テーブルビューでは機能しません。
于 2011-06-23T14:14:58.383 に答える
3
NSIndexPathクラスの以下のメソッドを使用します 。
+ (id)indexPathWithIndex:(NSUInteger)index;
+ (id)indexPathWithIndexes:(NSUInteger *)indexes length:(NSUInteger)length;
- (id)initWithIndex:(NSUInteger)index
以下のように使用し、使用後も反対することを忘れないでくださいrelease
myIndexPath
。
NSIndexPath *myIndexPath = [[NSIndexPath alloc] initWithIndex:[myIntObj intValue]];
于 2011-06-23T13:24:40.070 に答える
2
スウィフト3:
let indexPath = IndexPath(row: 0, section: 0)
于 2016-10-24T20:56:25.100 に答える