用户可以切换到禁用了用户交互的 UITextField
User can tab to a UITextField that has user interaction disabled
我在 UITextField 中禁用了用户交互:
textField.isUserInteractionEnabled = false
而且(至少在模拟器中)用户仍然可以切换到该字段并输入数据。要解决此问题,我必须在我的 UITextFieldDelegate 中执行以下操作:
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
// This seems really odd.
return isUserInteractionEnabled
}
UITextField 中的错误?或预期的行为? (这是 iOS 11.4 运行 在 Xcode 9.4.1 下。)
尝试设置 textField.enabled = false。
这是一个属性UIView上的UIControl界面。
来自UIControl.h评论:如果否,忽略触摸事件,子类可能会绘制不同。
我在 UITextField 中禁用了用户交互:
textField.isUserInteractionEnabled = false
而且(至少在模拟器中)用户仍然可以切换到该字段并输入数据。要解决此问题,我必须在我的 UITextFieldDelegate 中执行以下操作:
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
// This seems really odd.
return isUserInteractionEnabled
}
UITextField 中的错误?或预期的行为? (这是 iOS 11.4 运行 在 Xcode 9.4.1 下。)
尝试设置 textField.enabled = false。
这是一个属性UIView上的UIControl界面。
来自UIControl.h评论:如果否,忽略触摸事件,子类可能会绘制不同。