选择 UITextField 文本时隐藏选项菜单

Hide option menu when UITextField text is selected

简而言之,我们如何在选择 UITextField 文本时阻止弹出菜单。

所需功能:

用户可以点击任一字段并编辑文本。 当字段被点击且 textField 为空时,我会生成文本 textfield.selectAll(self)。这就是弹出菜单的点。

How to disable UITextField editing but still accept touch? 答案没有解决这个问题,也不允许用户继续使用 textField。

找到回复:

使用 textField.selectAll() 时,传递 textField 的委托会使弹出菜单出现。

如果没有弹出菜单,请使用 textField.selectAll(nil)