简体   繁体   中英

How do disable back swipe gesture in UINavigationController in iOS 8?

self.navigationController.interactivePopGestureRecognizer.enabled = NO;

This line no longer seems to have any effect in iOS 8. Putting it in my viewDidLoad method still enables the back swipe gesture with a navigation controller. Any ideas?

Setting a custom back button image generally does the trick.

self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc]
    initWithTitle:@""
    style:UIBarButtonItemStylePlain
    target:nil
    action:nil];

As an aside I generally recommend against breaking the built in behaviors like this, especially since most iOS users are very familiar and comfortable with these gestures. Taking them out just serves to frustrate users unnecessarily.

So if you are using the system standard navigation bars then it definitely stands to reason that people expect system standard behaviors. If you don't want these behaviors then you are better off customizing the UI: In this scenario this means either using your own Navigation bar and setting the navigation controller's bar to hidden.

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