I have a UITextfield
for entering password with SECURE
attribute enabled.
When the user taps outside the UITextfield
after inputting a certain number of characters, and then taps back again to the UITextfield
for editing, the following behavior is taking place:
iOS 5.1
-When I try to delete a character(using backspace
from keyboard) from the UITextfield
, the last character is deleted.
iOS 6.0
-When I try to delete a character from the UITextfield
, all typed characters are getting deleted.
Am I doing something wrong, or is this a bug in iOS 6?
This is the intended behaviour under iOS6 and you shouldn't probably change it.
If for whatever reason you really need this, you can override
UITextField
's delegate methodtextField:shouldChangeCharactersInRange:replacementString:
and restore the old behaviour:Looks like this can be fixed by explicitly setting secureTextEntry to NO in viewDidLoad or thereabouts.
This seems to work with the case described above (a view with an email field and a secure password field on it), under iOS 6.
HTH!
There is also an issue with iOS 6 w/ regard to this new behavior. Try this:
Viola! You have nothing in your text field now. I am able to reproduce this consistently with iOS 6.0.x and 6.1
Here is a way to detect if a secure field is going to be cleared by a backspace:
iOS 6 UITextField Secure - How to detect backspace clearing all characters?