方法一:
参考文章:点这里
方法二:
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.navigationController.navigationBar setHidden:NO];
//在其他离开改页面的方法同样加上下面两句代码
self.isTapBack = YES;
if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
}
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.isTapBack = NO;
if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;
}
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer
*)gestureRecognizer{
return self.isTapBack; //YES:允许右滑返回 NO:禁止右滑返回
}