Reputation: 560
Is there any way to change the 'selected' member of a UICollectionViewCell that is not in the "visibleCells"? (beside saving the Cell object of the last selected cell...)
Upvotes: 0
Views: 575
Reputation: 9144
In order to change the selected status of an item you should call the method selectItemAtIndexPath:
Items can be reused, so if you call the setSelected
method of UICollectionViewCell, it might not select the right item.
[self.collectionView selectItemAtIndexPath:indexPath animated:NO scrollPosition:UICollectionViewScrollPositionNone];
If you want to deselect it you have this method:
[self.collectionView deselectItemAtIndexPath:indexPath animated:NO];
Upvotes: 1