Set a Passwordfield to Securetextentry Give Me a Strange Behaviour

Set a PasswordField to secureTextEntry give me a strange behaviour

This happens when the system's user doesn't have iCloud Keychain enabled. As will often be the case on the Simulator :)

I ran into this on the simulator and came here. Tried it on my phone (where iCloud Keychain is enabled), and got this instead:

[AutoFill] Cannot show Automatic Strong Passwords for app bundleID:
your.bundle.id due to error: Cannot save passwords for this app. Make
sure you have set up Associated Domains for your app and AutoFill
Passwords is enabled in Settings

So this is Apple's cool AutoFill feature. There are some steps described here that should enable that.

Cannot show Automatic Strong Passwords for app bundleID when signup

Automatic Strong Passwords suggestion works if user has enabled the iCloud keychain in its iPhone. I resolved this error by doing the following steps

How to enable iCloud keychain

  1. Go to the Setting
  2. Tap on UserName (Apple Id)
  3. Tap on iCloud
  4. Tap on keychain
  5. Enable iCLoud Keychain

Change UIFont in secure UITextField strange behaviour in iOS7

As a couple people pointed out, it appears secure text fields don't always play well with custom fonts. I worked around this by using the UITextField's UIControlEventEditingChanged to monitor for changes to the textfield and set it to the system font (with the normal looking bullet points) when anything is entered, else use my custom font.

This allows me to keep using my custom font for the textfield placeholder and still look good when the password is entered. The characters that show one-at-a-time while being entered will be the system font, but I'm okay with that.

In viewDidLoad:

[self.passwordTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];

Now add a textFieldDidChange method:

- (void)textFieldDidChange:(id)sender
{
UITextField *textField = (UITextField *)sender;

if (textField == self.passwordTextField) {
// Set to custom font if the textfield is cleared, else set it to system font
// This is a workaround because secure text fields don't play well with custom fonts
if (textField.text.length == 0) {
textField.font = [UIFont fontWithName:@"OpenSans" size:textField.font.pointSize];
}
else {
textField.font = [UIFont systemFontOfSize:textField.font.pointSize];
}
}
}

Native UITextField Secure Text Entry forces English (US) keyboard

This was truly an iOS bug => corrected in iOS 12.1

UITextField with secure entry, always getting cleared before editing

Set,

textField.clearsOnBeginEditing = NO;

Note: This won't work if secureTextEntry = YES. It seems, by default, iOS clears the text of secure entry text fields before editing, no matter clearsOnBeginEditing is YES or NO.



Related Topics



Leave a reply



Submit