UICollectionView cellForItemAtIndexPath indexPath row nil

The first time I use UICollectionView . I am trying to get the string value for each cell - to be used as an identifier / tag for the cells text field. When cellForItemAtIndexPath is cellForItemAtIndexPath , it seems that [indexPath row]; returns nil . How can I get the cell index (or something else to use as an identifier) ​​when the row is zero?

Note Using iOS7, if that matters ...

 - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { // Returns nil NSLog("Row: %d", indexPath.row); } 

Any ideas / tips?

+4
source share
1 answer

You do not use the concept of a string in a collection view. You should use this method from NSIndexPath :

 + (NSIndexPath *)indexPathForItem:(NSInteger)item inSection:(NSInteger)section; 

Note that the row property for NSIndexPath declared on UITableView.h , and the item property is declared on UICollectionView.h

+6
source

Source: https://habr.com/ru/post/1496215/


All Articles