我想知道如何禁用 UITextField
,即出于设计目的,我在 UITextField
的框架中放置了一个 UIButton
。
当我在 UITextField
中点击我的按钮时,键盘出现了,但我不想显示键盘!
到目前为止,这是我的代码:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
return textField !=textfiled1;
return textField !=textfiled2;
}
最佳答案
您可以使用此属性在文本字段上启用或禁用用户交互:
textField.userInteractionEnabled = NO;
在 swift 5 中
textField.isUserInteractionEnabled = false
关于ios - 设置 UITextField 不可编辑或可编辑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29821562/