Just to add my $ 0.02, I tried both versions of the selected answer, and the original way worked better for my purposes. I am working on endlessly viewing a scroll calendar that allows the user to enter a calendar for a given week, and then scroll back and forth and select individual days to filter the list.
In my implementation, in order to maintain performance on older devices, the array of dates representing the calendar view should be relatively small, which means that it should contain dates at 5 weeks, and the user in the middle at the third week. The problem with using the second approach is that there is a second step in which you need to scroll the collection view to the middle without animation, which for some reason creates a very uneven appearance with the base animation blocked.
My code is:
[UIView setAnimationsEnabled:NO]; [self.collectionView performBatchUpdates:^{ [self.collectionView deleteItemsAtIndexPaths:indexPathDeleteArray]; [self.collectionView insertItemsAtIndexPaths:indexPathAddArray]; } completion:NULL]; [UIView setAnimationsEnabled:YES]; NSIndexPath *newIndexPath = [NSIndexPath indexPathForItem:14 inSection:0]; [self.collectionView scrollToItemAtIndexPath:newIndexPath atScrollPosition:UICollectionViewScrollPositionLeft animated:NO];
Matt S. Jun 08 '14 at 1:56 on 2014-06-08 01:56
source share