As per this article http://aplus.rs/2014/how-to-animate-in-uicollectionview-items/ I am trying to load a UICollectionViewCell one at a time to animate the cell when it appears. However, when I call the code the loops the cellCount++, it produces this error:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (1) must be equal to the number of items contained in that section before the update (1), plus or minus the number of items inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).'
And I cannot for the life of me figure it out.
Here is my code:
-(void)addCells{
for (self.cellCount=0; self.cellCount<50; self.cellCount++) {
[self.collectionView performBatchUpdates:^{
[self.collectionView insertItemsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForItem:self.cellCount inSection:0]]];
} completion:nil];
}
}