私はUICollectionView
にいくつかの細胞を持っています。セルの番号を取得するには?
私はここにいくつかのテストをした:それはログに表示されている。ここ
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath];
NSLog(@"nsindex path %@", indexPath);
cell.backgroundColor=[UIColor greenColor];
return cell;
}
は、一つのセルの例である:私はから(path = 0 - 1
から)値1
を抽出する方法を
nsindex path <NSIndexPath: 0xc000000000200016> {length = 2, path = 0 - 1}
この例のオブジェクト?
この回答の最初の文は正しくありません。この質問は 'UICollectionView'に関するものなので、正解は' indexPath.row'ではなく 'indexPath.item'を使うことです。 – rmaddy
私はあなたのコメントに応じて答えを更新しました! :) –