iOS Tips and Tricks


Disable back swipe gesture in UINavigationController

From iOS 7 there is a new navigation behavior.
You can swipe from left border of the screen to go back on navigation stack.

How can you disable this behavior? Get the solution below (replace self.navigationController with self when you are in the UINavigationController class)

Swift :

self.navigationController?.interactivePopGestureRecognizer.enabled = false;

Objective C :

if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}

Reference Links:
1. https://bhaveshdhaduk.wordpress.com/2014/05/17/ios-7-enable-or-disable-back-swipe-gesture-in-uinavigationcontroller/
2. http://stackoverflow.com/questions/17209468/how-to-disable-back-swipe-gesture-in-uinavigationcontroller-on-ios-7
3. http://stackoverflow.com/questions/19019900/how-to-turn-off-the-automatic-gesture-to-go-back-a-view-with-a-navigation-contro

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.