Easy way to disable a UITextField?

CC. picture CC. · Mar 1, 2009 · Viewed 57.5k times · Source

Is there an easy way to disable a UITextField in code?

My app has 12 UITextField that are all turned on by default, but when a change is detected in my Segment Control I want to disable some of the UITextField depending on what Segment the user picks.

Just need to know how to disable it or make it non-editable?

Thanks

Answer

Joel Levin picture Joel Levin · Mar 1, 2009

In Objective-C:

textField.enabled = NO;

In Swift:

textField.isEnabled = false

Reference: UIControl.isEnabled