iOS7 nested push animation can result in corrupted

在iOS7中,开启push/pop view controller 动画遇到一个问题,就是在快速切换多次后会在console出现一个问题

nested push animation can result in corrupted navigation bar multiple warning
Unbalanced calls to begin/end appearance transitions for

查了一些资料后,找到了一个方法:

0)找到push/pop view controller 动画结束的回调。

UINavigationControllerDelegate代理中的

-(void)navigationController:(UINavigationController *)navigationController
  didShowViewController:(UIViewController *)viewController
               animated:(BOOL)animated

1)找到是否接受点击方法的方法。

UIGestureRecognizerDelegate中的

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch

应用以上两个代理方法,加上一个BOOL的flag值,可以控制是否处罚pop/push

当动画完成时,将flag设置为允许pop/push, shouldReceiveTouch直接返回flag值。

在点击事件时,要注意更改flag值不再接受其他事件,防止在flag为YES时的多次点击。

参考链接:

http://stackoverflow.com/questions/11813091/nested-push-animation-can-result-in-corrupted-navigation-bar-multiple-warning

http://www.taofengping.com/2013/12/26/ios7_barbuttonitem_navigation_gesture/

http://blog.csdn.net/lengshengren/article/details/12616217

http://stackoverflow.com/questions/10150231/how-to-detect-when-uinavigationcontroller-animation-has-finished