Vitaly S.
Vitaly S.

Reputation: 2389

UICollectionView cell can't be selected after reload in case if cell was touched during reloading

I use UICollectionView to display server-related information. This UICollectionView allows cells selection to display some nested data. Unfortunately if user touches and holds any cells during my app calls [collectionView reloadData] this cell doesn't react on touches anymore (collectionView:didSelectItemAtIndexPath: method isn't called). I can select any cells except this one.

I created simple application that can reproduce this problem: link

Any ideas how to fix it?

Upvotes: 11

Views: 7411

Answers (2)

Alladinian
Alladinian

Reputation: 35626

Looks like a bug (I believe there is a similar issue where a cell.selected = YES without a -selectItemAtIndexPath:animated:scrollPosition: caused the cell to be unable to be unselected)

However if you do this:

[self.collectionView reloadItemsAtIndexPaths:[self.collectionView indexPathsForVisibleItems]];

instead of [self.collectionView reloadData] it is working as expected.

Update: Found the answer of the issue mentioned above

Another Update: It appears that this indeed was a bug. Tested the original project on the iOS8 simulator and the issue now is resolved.

Upvotes: 18

iPatel
iPatel

Reputation: 47059

As per @Alladinian's answer says that instead of use of [self.collectionView reloadData], use self.collectionView reloadItemsAtIndexPaths:..... worked in your demo and also I did tried with

[self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];

Its also worked properly.

Upvotes: 2

Related Questions