UINavigationController custom animation prevents swipe-to-go-back from working

前端 未结 2 1916
一整个雨季
一整个雨季 2021-02-14 16:45

I noticed something strange and may possibly be a bug in UINavigationController. When you override -navigationController:animationControllerForOperation:fromViewController

相关标签:
2条回答
  • 2021-02-14 17:29

    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.

    0 讨论(0)
  • 2021-02-14 17:38

    This SO question is about the same subject and this answer may fix the issue :

    https://stackoverflow.com/a/20923477/145710

    0 讨论(0)
提交回复
热议问题