3

When using a UITextField in an iOS app, I can set secure text entry to YES, which will obscure all but the last character typed into the field. However, I can also enable autocorrection at the same time.

Does anyone know what happens in that case? If my password is "bananas" and I start typing it into the field, it's not helpful for the text to be obscured, if the it's is also going to be autocorrected.

jscs
  • 63,694
  • 13
  • 151
  • 195
Daniel
  • 31
  • 5
  • 2
    While it's an interesting thought experiment - shouldn't you be explicitly disabling this anyways. Along with capitalization etc.. – Michael Kernahan Nov 09 '12 at 17:08
  • I would if I was writing the code - I'm not. I'm reviewing someone else's code, and I don't want to make work for them if it's not an issue. – Daniel Nov 09 '12 at 20:40

1 Answers1

1

As @Michael Kernahan said, this is an interesting thought experiment. I had never thought about it before but just to be sure that my hunch that the field wouldn't autocorrect held true, I created a small Xcode project to test the concept.

After creating the (admittedly crude) interface in IB, I used the default omw autocorrect to test the field as a control. Without specifically enabling autocorrect on the field, the autocorrection occurred.

Autocorrect works!

I set the field to be secure by calling

[secureTextField setSecureTextEntry:YES];

and running the test again. The test failed and the field did not autocorrect.

Autocorrect doesn't work :(

Finally, as you describe in your question, I set the secure text field's autoCorrectionType to UITextAutocorrectionTypeYes and the test failed yet again.

Autocorrect doesn't work yet again :(


To answer your question more briefly, based on these tests setting UITextField to take secure input disables the autocorrective attributes of the field, regardless of whether they are explicitly enabled or not (as expected and as it should be).

esqew
  • 42,425
  • 27
  • 92
  • 132