How do I know that the UICollectionView has been loaded completely?

Jirune picture Jirune · Dec 24, 2012 · Viewed 71.1k times · Source

I have to do some operation whenever UICollectionView has been loaded completely, i.e. at that time all the UICollectionView's datasource / layout methods should be called. How do I know that?? Is there any delegate method to know UICollectionView loaded status?

Answer

myeyesareblind picture myeyesareblind · Jun 5, 2015

This worked for me:

[self.collectionView reloadData];
[self.collectionView performBatchUpdates:^{}
                              completion:^(BOOL finished) {
                                  /// collection-view finished reload
                              }];

Swift 4 syntax:

self.collectionView.reloadData()
self.collectionView.performBatchUpdates(nil, completion: {
    (result) in
    // ready
})