I had similar problems with UITableView
which I solved by the following code:
[CATransaction begin];
[CATransaction setCompletionBlock:onCompletion];
[CATransaction setAnimationDuration:duration];
[self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:3 inSection:3]
atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally
animated:YES];
[CATransaction commit];
Obviously, you can’t call it with animated:NO
because the animation code inside the method is important. Using a CATransaction
to wrap the animation worked for me.