简体   繁体   English

用户可以切换到禁用了用户交互的UITextField

[英]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.

相关问题 禁用了用户交互的UITableViewCell和UITextField不会调用didSelectRow - UITableViewCell and UITextField with user interaction disabled doesn't call didSelectRow 如何从动态创建的UITextField中获取文本而无需触摸或点击文本字段(禁用用户交互)? - How to get text from dynamically created UITextField without touching or tapping the text field (disabled user interaction)? UICollectionView单元格用户交互已禁用 - UICollectionView cell user interaction disabled 在子视图的子视图中禁用了用户交互 - User Interaction disabled in subview of a subview 禁用UITextField上的触摸但不是所有用户交互 - Disable touches but not all user interaction on UITextField Adhoc应用程序iO中的UITextField用户交互问题 - UITextField user interaction issue in Adhoc application iOs UIView中的UITextField没有响应用户交互 - UITextField within UIView not responding to user interaction 防止在 Swift 中编辑 UITextField 而不是用户交互 - Prevent editing UITextField but not the user interaction in Swift 如何在禁用用户交互的情况下为子视图实现longPressGestureRecognizer? - How implement longPressGestureRecognizer for subview with disabled user interaction? 在iOS 7的UIViewController上禁用了子视图用户交互 - subview user interaction disabled on UIViewController on iOS 7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM