且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Swift中禁用向后滑动手势

更新时间:2022-05-13 07:08:47

您可以禁用它,但是不建议这样做,因为大多数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;