![](/img/trans.png)
[英]UITableViewCell and UITextField with user interaction disabled doesn't call didSelectRow
[英]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中的错误? 还是预期的行为? (这是在Xcode 9.4.1下运行的iOS 11.4。)
尝试设置textField.enabled = false。
这是UIView上UIControl接口的属性。
从UIControl.h注释:如果为NO,则忽略触摸事件,并且子类的绘制方式可能有所不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.