在这里找了一段时间,但似乎找不到有效的解决方案.
Been looking around on here for a while but can't seem to find a working solution.
我正在尝试在 Swift 中禁用滑动以返回上一个视图手势.
I'm trying to disable the swipe to go back to previous view gesture, in Swift.
我尝试了多种解决方案,包括:
I've tried a variety of solutions including:
self.navigationController?.interactivePopGestureRecognizer.enabled = false
和
self.navigationController.interactivePopGestureRecognizer.delegate = self
func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer!) -> Bool {
return false
}
有没有一种新方法可以做到这一点或其他一些有效的方法?
Is there a new method of doing this or some other method that works?
您可以禁用它,但不建议这样做,因为大多数 iOS 用户通过滑动返回而不是按返回按钮.如果你想禁用它,使用 modal segue
代替推送 segue 会更合理,因为推送的转移不是那么大.如果你真的想摆脱滑动返回功能,我会禁用返回按钮并在屏幕右上角有一个完成按钮.
You could disable it but that would not be to recommended as most iOS users go back by swiping and less by pressing the back button.
If you want to disable it it would be more reasonable to use a modal segue
instead of a push segue which is not that big of a transfer.
If you really want to get rid of the swipe to go back function I would just disable the back button and have a done button on the top right of the screen.
self.navigationController?.navigationItem.backBarButtonItem?.isEnabled = false;
这篇关于在 Swift 中禁用向后滑动手势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!