Reputation: 5790
I have a one dimensional array of images that I am feeding to a UICollectionView.
The collection view is just one section composed of the elements in the array.
when I click a cell and -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath;
gets fired off and I do a print out of the indexPath I get values like [0,0] for element 0 in row 0 but then the very next element in that row is [0,5].
How can I map the indexPath to my array like the way UITableView
's [indexPath row] matches directly to the corresponding index?
Upvotes: 10
Views: 21877
Reputation: 491
To Retrieve item index you need to use indexPath.item(for UICollectionView) not indexPath.row(it's for UITableView)
Upvotes: 10
Reputation: 10129
I've never used them, but my understanding is that the two properties of a UICollectionView's indexPath are section and item, not section and row like in a UITableView.
Upvotes: 20