TextField.clearButtonMode = / * regardless * / does not work

I create a textField and add it to the view as follows:

UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(/*blah blah */)]; textField.borderStyle = UITextBorderStyleRoundedRect; textField.clearButtonMode = UITextFieldViewModeAlways; [otherView addSubview:textField]; 

The text box is displayed as expected in the otherView , but the clear button is never displayed, no matter what value I assign to clearButton. Does anyone know what could be causing this?

+4
source share
1 answer

The answer is that UITextField.clearButtonMode working. When the text field matters, the button is. I guess I assumed that “Always” means “Always” when it really means “when .text != nil ”.

+8
source

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


All Articles