用了自定义返回按钮,开启了self.navigationController?.interactivePopGestureRecognizer.delegate=self后解决滑动返回问题,但是在在一级视图中,同样以返回的手势滑动一下,然后本来应该进入二级视图,但是画面卡住了,按Home键转入后台,再返回应用,发现并没有Crash掉,而是直接跳到了二级视图里。查阅了网上的教程,他的解决办法是:
“一级视图中一定要加入self.navigationController.interactivePopGestureRecognizer.enabled = NO;,先把iOS7手势返回屏蔽掉,到二级视图再用self.navigationController.interactivePopGestureRecognizer.enabled = YES打开。”
但是我这样做后,依然会出现这个问题,依然一级界面滑动会卡死。部分代码如下:
一级视图:
self.navigationController?.interactivePopGestureRecognizer.enabled=false
self.navigationItem.setHidesBackButton(false, animated: true)
self.navigationController?.navigationBarHidden=true
self.navigationController?.interactivePopGestureRecognizer.delegate=self
self.navigationController?.navigationBarHidden=false
self.navigationController?.interactivePopGestureRecognizer.enabled=true
如果是二级视图右滑可pop到一级视图,也就是navigationcontroller 的rootcontroller. 这个一级视图是导航控制器的顶层,它没有了上一级的视图,所以是不是因为这个原因。
或许可以尝试自己实现。用到的技术点
1. UIScreenEdgePanGestureRecognizer . 响应按住边缘的手势
2. 自定义uiViewcontroller的转场动画 ,需要实现UIViewControllerAnimatedTransitioning协议
3. 自定义uiviewcontroller的转场交互。需要实现 UIViewControllerInteractiveTransitioning协议,可返回系统已实现的类UIPercentDrivenInteractiveTransition