在Swift中禁用向后滑动手势 [英] Disable swipe back gesture in Swift

查看:682
本文介绍了在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而不是不那么大的传递推键是更合理的. 如果您真的想摆脱滑动返回功能,则只需禁用返回"按钮,然后在屏幕右上方有一个完成"按钮即可.

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中禁用向后滑动手势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆