How to reliably determine when a UICollectionView layout has completed an animation

I'm having trouble figuring out a way to determine when a UICollectionView is completed by an animation.

I currently have a UICollectionView that animates between two layouts of a stream subclass using setCollectionViewLayout:animated:

The animation looks great, but I get the wrong behavior if the user selects a cell during the animation.

I look at ignoring cell selection by returning NO through the UICollectionViewDelegate collectionView:shouldSelectItemAtIndexPath: - however - I cannot find a reliable test to see if viewing the collection is now animating.

Any ideas?

+6
source share
1 answer

Try checking for animated keys.
BOOL isAnimating = myView.layer.animationKeys.count > 0

+2
source

Source: https://habr.com/ru/post/949912/


All Articles