IOS: UItextfield disabled

2019-02-17 07:52发布

When we push on a textfield, a cursor appear in this textfield; but I don't want that this cursor appear; then I want make this textfield disabled, where you can't write inside, how can I do?

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-02-17 07:56

Can you set enabled property/userInteractionEnabled of text field to No in ViewDidLoad() using the code

textField.enabled = NO;

or

textField.userInteractionEnabled = NO;
查看更多
Viruses.
3楼-- · 2019-02-17 08:04

If you're working with storyboards or .nib files and you want it to start out disabled you can also easily uncheck the enabled property in interface builder for some time-saving.

查看更多
登录 后发表回答