UINavigationController custom animation prevents work from moving to work

I noticed something strange and might be a bug in the UINavigationController. When you override -navigationController:animationControllerForOperation:fromViewController:toViewController:

and return nil (for default animation behavior), the drag and drop gesture does not work. The documentation for this method states that you must return "nil if you want to use the standard navigation controller transitions." My reading of this is that returning nil should not interfere with the default behavior.

I also found that if the navigation controllers are interactivePopGestureRecognizer.delegate with something that returns YES for gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer: pop gesture works again. However, this workaround is risky, as we stomp on the default delegate set, which is _UINavigationInteractiveTransition.

Is there any way to override the animationController method while retaining the default gesture to drag backwards?

This question is related.

+5
source share
2 answers

This SO question refers to the same question, and this answer can solve the problem:

fooobar.com/questions/352675 / ...

+1
source

If you subclass the 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 the UIViewController:

 override func viewDidLoad() { super.viewDidLoad() navigationController?.interactivePopGestureRecognizer?.delegate = nil } 

Implementing the delegate method navigationController(_:animationControllerFor:from:to:) disables the gesture recognition recognizer of the navigation controller, but setting the delegate gesture to nil reactivates it.

If you want the gesture to be included in certain circumstances, see this answer .

+1
source

Source: https://habr.com/ru/post/1201366/


All Articles