轻松禁用UITextField的方法?

轻松禁用UITextField的方法?

问题描述:

是否有一种简单的方法可以在代码中禁用 UITextField

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

我的应用有12 UITextField 默认情况下全部打开,但是当我的段控件中检测到更改时,我想禁用部分 UITextField 取决于用户选择的细分。

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?

谢谢

在Objective-C中:

In Objective-C:

textField.enabled = NO;

在Swift中:

textField.isEnabled = false

参考: UIControl.isEnabled