How to enable back/left swipe gesture in UINavigationController after setting leftBarButtonItem?

前端 未结 14 967
遥遥无期
遥遥无期 2020-11-28 22:48

I got the opposite issue from here. By default in iOS7, back swipe gesture of UINavigationController\'s stack could pop the presented ViewCon

14条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-28 23:09

    Setting a custom back button disable the swipe back feature.

    The best thing to do to keep it is to subclass UINavigationViewController and set itself as the interactivePopGestureRecognizer delegate; then you can return YES from gestureRecognizerShouldBegin to allow the swipe back.

    For example, this is done in AHKNavigationController

    And a Swift version here: https://stackoverflow.com/a/43433530/308315

提交回复
热议问题