Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextField secureEntry misplaces cursor

I'm having issues with toggling the secureEntry property on UITextField. When the property is toggled, the characters are resized, but the cursor stays in the wrong place:

insecure entrysecure entry

like image 747
HighFlyingFantasy Avatar asked Mar 25 '14 15:03

HighFlyingFantasy


2 Answers

Here is my workaround:

textField.secureTextEntry = YES;

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

Disable and then Enable the UITextField also help, but it will suddenly change my soft keyboard from one to another

like image 73
0x5e Avatar answered Oct 04 '22 06:10

0x5e


After setting textField secureEntry property NO, you need to call becomeFirstResponder method its works for me...

Try this

 textField.secureTextEntry = NO;
 if (textField.isFirstResponder){
    [textField becomeFirstResponder];
 }
like image 32
keshav vishwkarma Avatar answered Oct 04 '22 06:10

keshav vishwkarma