[英]User can tab to a UITextField that has user interaction disabled
I have disabled user interaction in a UITextField: 我在UITextField中禁用了用户交互:
textField.isUserInteractionEnabled = false
and still (at least in the simulator) the user can tab to that field and enter data. 仍然(至少在模拟器中)用户可以跳至该字段并输入数据。 To work around this, I've had to do the following in my UITextFieldDelegate:
要解决此问题,我必须在UITextFieldDelegate中执行以下操作:
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
// This seems really odd.
return isUserInteractionEnabled
}
A bug in the UITextField? UITextField中的错误? Or behavior as intended?
还是预期的行为? (This is with iOS 11.4 running under Xcode 9.4.1.)
(这是在Xcode 9.4.1下运行的iOS 11.4。)
Try setting textField.enabled = false. 尝试设置textField.enabled = false。
This is a property of UIControl interface on UIView. 这是UIView上UIControl接口的属性。
From UIControl.h comment: if NO, ignores touch events and subclasses may draw differently. 从UIControl.h注释:如果为NO,则忽略触摸事件,并且子类的绘制方式可能有所不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.