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 中禁用向后滑动手势
基础教程推荐
- 在 iOS 7 下 CCMenu 错位 2022-01-01
- 在视图控制器的宽度上水平均匀分布 UIButton 的最简单方法? 2022-01-01
- EditText 中的 setHintTextColor() 2022-01-01
- 从 UIWebView 访问元数据 2022-01-01
- UINavigationBar 隐藏按钮文本 2022-01-01
- Android - 如何在runOnUiThread 中将数据传递给Runnable? 2022-01-01
- 更改 UITableView 部分标题的颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- UINavigationItem 的持久 rightBarButtonItem 属性 2022-01-01
- Firebase 云消息传递令牌未生成 2022-01-01