我需要在我的应用中禁用interactivePopGestureRecognizer,我做了
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// Disable iOS 7 back gesture
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)])
{
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
self.navigationController.interactivePopGestureRecognizer.delegate = self;
}
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
// Enable iOS 7 back gesture
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)])
{
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
}
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
return NO;
}
适用于'iOS8',我在'iOS9'上有一个问题。
答案 0 :(得分:1)
如果要禁用interactivePopGestureRecognizer global,可以在创建navigationController后禁用它。
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:rootVC];
nav.interactivePopGestureRecognizer.enabled=NO;