How to turn off the automatic swipe to go back in navigation controller? Swift

旧巷老猫 提交于 2019-12-11 14:48:48

问题


I need to turn off the automatic gesture swiping to go back in navigation controller. I using Swift.

I have already searched but didn't found a solution for me.


回答1:


You can disable the interactivePopGestureRecognizer of your navigationController:

self.navigationController?.interactivePopGestureRecognizer.enabled = false



回答2:


self.navigationController.interactivePopGestureRecognizer.delegate = self

func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer!) -> Bool {
return false;
}

I found this after a couple little searches. Not sure if its correct or not.




回答3:


Swift version: Add this delegate in your UIViewController: UIGestureRecognizerDelegate

Then in your viewDidLoad() method add the next line:

self.navigationController!.interactivePopGestureRecognizer.delegate = self

and finally add this delegate method:

func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
    return false
}

Good luck!



来源:https://stackoverflow.com/questions/28943151/how-to-turn-off-the-automatic-swipe-to-go-back-in-navigation-controller-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!