1
kobe1941 2015-07-20 10:47:04 +08:00
在BaseViewController里开启或禁用
-(void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { if ([self.navigationController.viewControllers count] > 1) { self.navigationController.interactivePopGestureRecognizer.enabled = YES; self.navigationController.interactivePopGestureRecognizer.delegate = self; }else{ self.navigationController.interactivePopGestureRecognizer.enabled = NO; self.navigationController.interactivePopGestureRecognizer.delegate = nil; } } } |
2
Zrocky 2015-07-20 11:51:02 +08:00
我是在自定义的NavigationController中写的
- (void)viewDidLoad { [super viewDidLoad]; self.delegate = self; self.popGestureDelegate = self.interactivePopGestureRecognizer.delegate; } #pragma mark - UINavigationControllerDelegate - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated { if (viewController == self.viewControllers[0]) { self.interactivePopGestureRecognizer.delegate = self.popGestureDelegate; }else { self.interactivePopGestureRecognizer.delegate = nil; } } |