禁止仅对UITextField进行编辑?
问题描述:
我尝试以下方法:禁止仅对UITextField进行编辑?
性能
enabled
和 “用户交互启用”;方法
textFieldShouldBeginEditing:
。
但他们禁用所有可能的操作与文本字段。我只需要禁用编辑,但允许用户复制文本值。如何实现这一点?
答
推荐推荐速递该应用还没有任何解决方法。尝试
YourTextField.editing = NO;
答
除了tasuhka的响应,确保 YourTextField.selectable = YES;
答
实施并设置以下UITextFieldDelegate
:
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
return NO;
}
这使得该领域不可编辑的同时仍保留该选择/复制功能。 editing
属性是只读和无关的。