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

前端 未结 14 871
遥遥无期
遥遥无期 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:31

    I did not need to add gestureRecognizer functions for it. It was enough for me to add following code blocks at viewDidLoad:

    override func viewDidLoad() {
        super.viewDidLoad()
        self.navigationController?.interactivePopGestureRecognizer?.delegate = nil
        self.navigationController?.interactivePopGestureRecognizer?.isEnabled = true
    }
    
    0 讨论(0)
  • 2020-11-28 23:32

    it works for me Swift 3:

        func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool {
            return true
        }
    

    and in ViewDidLoad:

        self.navigationController?.interactivePopGestureRecognizer?.delegate = self
        self.navigationController?.interactivePopGestureRecognizer?.isEnabled = true
    
    0 讨论(0)
提交回复
热议问题