在自定义backButton或隐藏导航栏后系统自带的侧滑返回会失效,这时如果我们想要侧滑返回效果,不用自己添加手势,只需添加以下代码就可以,当然要添加UIGestureRecognizerDelegate
代理
self.navigationController.interactivePopGestureRecognizer.delegate = self;
如果我们想指定某个页面用禁止侧滑返回怎么办?
在禁用的页面添加以下代码
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
最后在viewWillDisappear里添加代码
self.navigationController.interactivePopGestureRecognizer.enabled = YES;