Is there a way to make a UITextField non-editable by the user and provide only a copy menu without subclassing? I.e when the text field is touched it automatically selects all the text and only shows the copy menu.
If possible to do this without subclassing what are the interface builder options that need to be selected?
Thanks in advance.
simply do:
(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
return NO;
}
and also:
yourTextField.inputView = [[UIView alloc] init];
You can disable editing by setting the enabled
property of UITextField
to NO
.
textField.enabled = NO;
Note that doing this will also disable the copy/paste options. What you are asking for has been discussed before in this solution: Enable copy and paste on UITextField without making it editable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With