iOSpop返回手势向右滑动

Jan 8, 2017

根据这篇文章http://www.jianshu.com/p/349636eb3fca 这是一篇简书的技术文章和一篇优化的文章:http://blog.csdn.net/chenyong05314/article/details/40344763。
读懂几个信息:

  1. 如果你重新定义返回按钮,这个按钮变为自定义的leftBarButtonItem的时候,iOS7之后的pop手势交互就失效。
  2. 如果需要重新启用,你可以用自定义的导航栏,更改两个东西或者新添几个地方:
    1):@interface CBNavigationController : UINavigationController <UINavigationControllerDelegate, UIGestureRecognizerDelegate>
    在类别中声明需要接收两个协议
    2):
    `-(void)viewDidLoad
    {
    __weak CBNavigationController *weakSelf = self;
    if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)])
    {
    self.interactivePopGestureRecognizer.delegate = weakSelf;
    self.delegate = weakSelf;
    
    }
    }然后还有两个协议: 3):-(void)pushViewController:(UIViewController )viewController animated:(BOOL)animated{
    if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
    self.interactivePopGestureRecognizer.enabled = NO;
    }
    [super pushViewController:viewController animated:animated];
    }-(void)navigationController:(UINavigationController
    )navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if ([navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
    if ([navigationController.viewControllers count]==1) {
        navigationController.interactivePopGestureRecognizer.enabled = NO;
    }else{
        navigationController.interactivePopGestureRecognizer.enabled = YES;
    }
    
    }
    }`
    这样你就可以愉快的使用返回手势啦