且构网

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

在 Swift 中禁用向后滑动手势

更新时间:2022-05-13 07:09:23

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