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?
尝试检查是否没有动画键。
BOOL isAnimating = myView.layer.animationKeys.count > 0