I\'ve been updating my apps to run on iOS 7 which is going smoothly for the most part. I have noticed in more than one app that the reloadData
method of a
You can use this method
[collectionView reloadItemsAtIndexPaths:arayOfAllIndexPaths];
You can add all indexPath
objects of your UICollectionView
into array arrayOfAllIndexPaths
by iterating the loop for all sections and rows with use of below method
[aray addObject:[NSIndexPath indexPathForItem:j inSection:i]];
I hope you understood and it can resolve your problem. If you need any more explanation please reply.
Reloading some items didn't work for me. In my case, and only because the collectionView I'm using has just one section, I simply reload that particular section. This time the contents are correctly reloaded. Weird that this is only happening on iOS 7 (7.0.3)
[self.collectionView reloadSections:[NSIndexSet indexSetWithIndex:0]];
// GCD
DispatchQueue.main.async(execute: collectionView.reloadData)
// Operation
OperationQueue.main.addOperation(collectionView.reloadData)
// Operation
NSOperationQueue.mainQueue().addOperationWithBlock(collectionView.reloadData)
Force this on the main thread:
dispatch_async(dispatch_get_main_queue(), ^ {
[self.collectionView reloadData];
});
It happened with me too in iOS 8.1 sdk, but I got it correct when I noticed that even after updating the datasource
the method numberOfItemsInSection:
was not returning the new count of items. I updated the count and got it working.
Here is how it worked for me in Swift 4
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = campaignsCollection.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! Cell
cell.updateCell()
// TO UPDATE CELLVIEWS ACCORDINGLY WHEN DATA CHANGES
DispatchQueue.main.async {
self.campaignsCollection.reloadData()
}
return cell
}