i have a collection view which display two array of images with different section count's this will be toggled between two different view of one collectionview view
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
if (self.storyview)
{
return 4;
}
else
{
return 1;
}
}
Where i perform Batch updates of collection view. it is getting crashed because i have two section count's
[self.collectionView performBatchUpdates:^{
NSRange range = NSMakeRange(0, [self.collectionView numberOfSections]);
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:range];
[self.collectionView deleteSections:indexSet];
[self.collectionView insertSections:indexSet];
}
completion:^(BOOL finished) {
[self.collectionView reloadData];
}];
My Crash log is as below:
Assertion failure in -[UICollectionView _endItemAnimations], /SourceCache/UIKit_Sim/UIKit-3318.16.14/UICollectionView.m:3901
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections. The number of sections contained in the collection view after the update (4) must be equal to the number of sections contained in the collection view before the update (1), plus or minus the number of sections inserted or deleted (0 inserted, 1 deleted).'
Can anyone et me know how to avoid this?