You can swipe from the left edge of the screen to go back on the navigation stack. But in my app, this behavior conflicts with my custom left menu. So, is it possible to disable this new gesture in UINavigationController?
From the controller you want this to be enabled/disabled just
Swift:
self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false // or true
ObjC:
self.navigationController.interactivePopGestureRecognizer.enabled = NO; // or YES
For my usecase it was important to disable it just in a single view controller, because that one had to have a slider which could easily interfere with that gesture. So I tried as suggested to disable it in viewWillAppear, which worked, however it kept being disabled in subsequently pushed controllers to.
I'v tried then to enable it in viewWillDisappear, which however did break the app somehow. Meaning, if in child view controllers I did try to use the back swipe the app was freezing. Putting it in background and reopen from there got rid of the freezing, but with nasty side-effects, like black backgrounds and missing search bars and other ui elements in wrong places.
The "trick" that got it working for me at the end was
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.interactivePopGestureRecognizer?.delegate = nil
}
and without setting it back to the real delegate it did work so far
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With