So Over It
So Over It

Reputation: 3698

How to reliably determine when UICollectionView layout has finished animating

I'm having problems figuring out a way to determine when UICollectionView is/has finished animating.

I currently have a UICollectionView that animates between two subclassed flow layouts using setCollectionViewLayout:animated:

The animation looks great, however, I'm having some undesired behaviour if a user selects a cell during the animation.

I'm looking at ignoring the cell 'selection' by returning NO through the UICollectionViewDelegate method collectionView:shouldSelectItemAtIndexPath: - however - I cannot figure out a reliable test to see if the collection view is currently animating.

Any ideas?

Upvotes: 9

Views: 1447

Answers (1)

djg
djg

Reputation: 1283

Try checking that there are no animation keys.
BOOL isAnimating = myView.layer.animationKeys.count > 0

Upvotes: 5

Related Questions