Reloading a UICollectionView using reloadData method returns immediately before reloading data

前端 未结 3 1208
北海茫月
北海茫月 2020-12-07 19:34

I need to know when reloading a UICollectionView has completed in order to configure cells afterwards (because I am not the data source for the cells - other wise would have

3条回答
  •  轮回少年
    2020-12-07 20:02

    This is caused by cells being added during layoutSubviews not at reloadData. Since layoutSubviews is performed during next run loop pass after reloadData your cells are empty. Try doing this:

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

    I had similar issue and resolved it this way.

提交回复
热议问题