UITextField setting not editable or editable

I want to know how to disable UITextField, i.e. I placed UIButtonin the frame UITextFieldfor design purposes.

When I press the button in UITextField, the keyboard appears, but I do not want the keyboard to appear!

Here is my code:

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    return textField !=textfiled1;
    return textField !=textfiled2;
}
+10
source share
6 answers

You can enable or disable user interaction in the text field using this property:

textField.userInteractionEnabled = NO;
+9
source
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
  return NO;
} 

You can use this too

+2
source

, UIButton UITextField. bringToFromView select UIButton. Event . , .

.

0

Swift 4:

textField.isUserInteractionEnabled = false
0

.

textField.userInteractionEnabled = NO;
-1

: , textField.editable = NO;

,
textField.editable = YES;

-2

Source: https://habr.com/ru/post/1584238/


All Articles