UITextField secureEntry moves the cursor

I'm having trouble switching the property secureEntryto UITextField. When the property is switched, the characters change, but the cursor remains in the wrong place:

insecure entrysecure entry

+4
source share
2 answers

Here is my way:

textField.secureTextEntry = YES;

UITextRange *textRange = textField.selectedTextRange;
textField.selectedTextRange = nil;
textField.selectedTextRange = textRange;

Disable and then enable also UITextField, but it will suddenly change my soft keyboard to one another

+2
source

After setting the textField property, secureEntry NOyou need to call a method becomeFirstResponderthat works for me ...

try it

 textField.secureTextEntry = NO;
 if (textField.isFirstResponder){
    [textField becomeFirstResponder];
 }
+2
source

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


All Articles