xcode IOS:UItextfield 已禁用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5947965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 21:00:35  来源:igfitidea点击:

IOS: UItextfield disabled

objective-cxcodeioscursoruitextfield

提问by cyclingIsBetter

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?

当我们按下一个文本字段时,这个文本字段中会出现一个光标;但我不希望这个光标出现;那我想禁用这个textfield,里面不能写,怎么办?

回答by PgmFreek

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

您可以使用代码在 ViewDidLoad() 中将文本字段的启用属性/userInteractionEnabled 设置为否吗

textField.enabled = NO;

or

或者

textField.userInteractionEnabled = NO;

回答by BossBols

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.

如果您正在处理故事板或 .nib 文件,并且希望它在开始时被禁用,您还可以轻松地取消选中界面构建器中的 enabled 属性以节省一些时间。