I noticed something strange and may possibly be a bug in UINavigationController. When you override
-navigationController:animationControllerForOperation:fromViewController:toViewController:
and return nil (for the default animation behavior), the drag-to-go-back gesture no longer works. The documentation for this method says you should return " nil if you want to use the standard navigation controller transitions". My reading of this is that returning nil should not prevent the default behavior from happening.
I also found that if the navigation controllers's interactivePopGestureRecognizer.delegate with something that returns YES for gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:
The pop gesture works again. However, this workaround is risky since we are stomping on the default delegate that is installed, which is a _UINavigationInteractiveTransition.
Is there someway I can override the animationController method while retaining the default drag-to-go-back gesture?
This question is related.
If you've subclassed UINavigationController, the simplest fix is as follows (iOS 9.3, Swift 2.2):
override func viewDidLoad() {
super.viewDidLoad()
interactivePopGestureRecognizer?.delegate = nil
}
Alternatively, in any other instance of UIViewController:
override func viewDidLoad() {
super.viewDidLoad()
navigationController?.interactivePopGestureRecognizer?.delegate = nil
}
Implementing the delegate method navigationController(_:animationControllerFor:from:to:)
disables the navigation controller's interactive pop gesture recognizer, but setting the gesture's delegate to nil re-enables it.
If you only want the gesture to be enabled in particular circumstances, see this answer.
This SO question is about the same subject and this answer may fix the issue :
https://stackoverflow.com/a/20923477/145710
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