Ios – uicollectionview select an item immediately after reloaddata

iosuicollectionview

After calling -[UICollectionView reloadData] it takes some time for cells to be displayed, so selecting an item immediately after calling reloadData does not work. Is there a way to select an item immediately after reloadData?

Best Answer

Along the lines of this answer I found that calling layoutIfNeeded after reloadData seemed to effectively 'flush' the reload before I do other things to the collectionView:

[self.collectionView reloadData];
[self.collectionView layoutIfNeeded];
...

On the page I found this solution, some commenters indicated it didn't work for them on iOS 9, but it's been fine for me so your mileage may vary.

Related Topic