Reputation: 9169
I have several cells that are written onto a UICollectionView
and reloading them takes a long time. How can I reload only when the data of a cell is modified? Here's one thing I've tried:
if([oldDataSource count] != [currentDataSource count])
{
[collectionView reloadData];
}
Yet, I still don't want to deal with reloading the entire thing. I've also tried:
if([oldDataSource count] < [currentdataSource count])
{
//something was added. //reload the last item in the current data source
}
This also failed because I can't reload something that doesn't "exist" in memory yet. This method also doesn't work because if something was deleted from my data source, the Cell will still remain in the interface, and will crash if clicked on.
So, what's the best way to deal with edited cells?
Thanks!
Upvotes: 0
Views: 1724
Reputation: 2017
try and get the cell u want to change. then:-
setNeedsDisplay
on the cell. try any of these three. cheers. have fun
Upvotes: 1
Reputation: 3203
Reloads just the items at the specified index paths.
- (void)reloadItemsAtIndexPaths:(NSArray *)indexPaths
Discussion Call this method to selectively reload only the specified items. This causes the collection view to discard any cells associated with those items and redisplay them.
Upvotes: 2