navigation 系统自带交互手势

UINavigationController interactivePopGesture

iOS7 之后,引入交互手势,在NavigationController 的交互手势是 UIScreenEdgePanGestureRecognizer, 继承自 UIPanGestureRecognizer。

在本次交互手势启用中,遇到的问题
  1. 自定义leftBarItem (返回按钮)不响应交互手势了。
  2. navigationController 的 RootViewController 上多滑动几次卡死了。
  3. UIViewController 上 有 ScrollView,TableView, UIWebView。
  4. 如何开启/关闭 interactivePopGesture?
解决办法:
  1. self.navigationController.interactivePopGesture.delegate = self;
  2. 代码如下
    1. - (void)viewDidDisappear:(BOOL)animated {
      [super viewDidDisappear:animated];
      self.navigationController.interactivePopGestureRecognizer.enabled = NO;
      }
      - (void)viewWillDisappear:(BOOL)animated {
      [super viewWillDisappear:animated];
      self.navigationController.interactivePopGestureRecognizer.enabled = YES;
      }
  3. [self.myWebView.scrollView.panGestureRecognizer requireGestureRecognizerToFail:self.navigationController.interactivePopGestureRecognizer];
    1. //辅助代码,在上句不行的情况下,添加以下代码
      - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
      return YES;
      }
  4. self.navigationController.interactivePopGestureRecognizer.enabled = NO/YES;
阅读更多
文章标签: navgationController
个人分类: iphone
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭