首先需要引用两个Delegate
UIGestureRecognizerDelegate
UINavigationControllerDelegate
然后在loadView中增加
self.navigationController.delegate = self;
if (IsiOS7Later) {
self.navigationController.interactivePopGestureRecognizer.delegate = self;
}
在viewDidDisappear中释放掉
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
self.navigationController.delegate = nil;
}
最后添加方法
#pragma mark - UINavigationController Delegate
-(void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
if ([navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
navigationController.interactivePopGestureRecognizer.enabled = YES;
}
}