8

I've added 3 UITextFields to create a new account by entering a username in email address format, a new password and a password confirmation. As suggested in Enabling Password AutoFill on a Text Input View. I have configured the username field like this

userTextField.textContentType = .username  
userTextField.keyboardType = .emailAddress

and the new password fields like this

newPasswordTextField.textContentType = .newPassword  
confirmPasswordTextField.textContentType = .newPassword

Now, when the users enters an email address as username the newPasswordTextField is pre-filled with a suggestion for a strong password (as expected), but the confirmPasswordTextField isn't filled with the same suggested password. When the user directly taps into the newPasswordTextField without entering a username before both newPasswordTextField and confirmPasswordTextField are pre-filled with the same suggested password (also as suggested).

How can i combine this both situations that after the user enters a username both password fields will be pre-filled with the same password?

2
  • 2
    I'm facing the exact same issue and starting to bash my head against the walls. Did you ever figure it out?
    – tomahh
    Dec 6, 2018 at 17:28
  • Same problem here. Has anyone found a workaround? Jun 12, 2019 at 7:44

2 Answers 2

3

I was able to do autocomplete for 2 password fields by declaring the contentType of the first field as: .password

  1. .username
  2. .password
  3. .newPassword
2
  • note: it really have to be in that order of .password and .newPassword
    – Tobe
    Dec 20, 2019 at 10:42
  • Actually, it seems to works if only the confirmation field is set with textContentType as .newPassword. Just don't set textContentType for the first field, or set it to .none for example.
    – Jeremie
    Nov 12, 2020 at 13:51
2

iOS 14 update

The answer from cornr worked for iOS 12 and 13.

However, it fails since iOS 14 in our app, as it will now request access to Keychain to auto-fill the stored password.

It seems that per iOS 14 Apple made it finally match their docu example to create a new account or changing the password. This means that for both password fields .newPassword should be used.

Having that said, suggesting a strong password fails entirely for us on iOS 14.2. For more details see this post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.