简体   繁体   中英

How to disable interactivePopGestureRecognizer disable in iOS9

I need to disable the interactivePopGestureRecognizer in my App,I did

- (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;
}

It works for 'iOS8' ,I have an Issue on 'iOS9'.

If you want to disable interactivePopGestureRecognizer global,you can disable it after create the navigationController as bellow.

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:rootVC];
nav.interactivePopGestureRecognizer.enabled=NO;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM