Disable swipe back gesture in Swift(在 Swift 中禁用向后滑动手势)
问题描述
在这里找了一段时间,但似乎找不到有效的解决方案.
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 中禁用向后滑动手势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Swift 中禁用向后滑动手势


基础教程推荐
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- LocationClient 与 LocationManager 2022-01-01