I am new to UICollectionview.
I have made a simple sample were I can apply multiple selection of image. but I'am getting issue regarding selection, the issue is when I scroll collection view the check mark are added to other cells and the images array count is different at didSelectedItem
and didDeselectItem
.
Here is the sample code which i have tried Sample Link
When you scroll in a
CollectionView
(or a inTableView
for that matter), the cells are reused.To keep the selection while scrolling you need to keep an array of the selected
IndexPaths
and update the cells accordingly in yourcollectionView:cellForItemAtIndexPath:
. That means removing the checkmark or setting it if the selected array contains thisIndexPath
.