问题
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