Nirma Nirma - 1 year ago 97
iOS Question

How to properly get index from index path in a UICollectionView?

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
's [indexPath row] matches directly to the corresponding index?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download