简体   繁体   中英

User can tab to a UITextField that has user interaction disabled

I have disabled user interaction in a 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:

func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
    // This seems really odd.
    return isUserInteractionEnabled
}

A bug in the UITextField? Or behavior as intended? (This is with iOS 11.4 running under Xcode 9.4.1.)

Try setting textField.enabled = false.

This is a property of UIControl interface on UIView.

From UIControl.h comment: if NO, ignores touch events and subclasses may draw differently.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM