Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 431
So Over It Avatar asked Jul 21 '13 04:07

So Over It


1 Answers

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

like image 118
djg Avatar answered Nov 15 '22 05:11

djg