方案1
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
//在其他离开改页面的方法同样加上下面代码
if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}
}
方案2
- (void)viewDidAppear:(BOOL)animated {
[superviewDidAppear:animated];
self.isCanSideBack = NO;
if([self.navigationControllerrespondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.delegate=self;
}
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer)gestureRecognizer {
return self.isCanSideBack;
}
- (void)viewDidDisappear:(BOOL)animated {
[superviewDidDisappear:animated];
//在其他离开改页面的方法同样加上下面两句代码
self.isCanSideBack=YES;
if([self.navigationControllerrespondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
}
}