uicollectionview select an item immediately after reloaddata?

前端 未结 9 1204
自闭症患者
自闭症患者 2021-02-13 16:23

After calling -[UICollectionView reloadData] it takes some time for cells to be displayed, so selecting an item immediately after calling reloadData do

9条回答
  •  眼角桃花
    2021-02-13 16:39

    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.

提交回复
热议问题