Password field's keyboard switches from azerty to qwerty (sometimes) only on iOS 12

Viewed 3537

I code an iOS App in Swift 4, I'm french so I work with mobile phone in french language/french region.

With an iOS 12 device, my password field on my login page works perfectly fine (the auto-login with saved password even works and I didn't do anything to get this working), but on my register page, the field makes my keyboard switch from AZERTY to QWERTY.

There is just the AZERTY keyboard in my phone settings, and it happens with all the iOS 12 devices not just mine...

The only thing I do in code : (my UIView file is named RegisterView.swift)

fieldPwd = UITextField()
fieldPwdConfirm = UITextField()
fieldPwd.isSecureTextEntry = true
fieldPwdConfirm.isSecureTextEntry = true

Is there any fix to this issue ? Thanks !

4 Answers

I've found a solution for my project, maybe it can help someone.

I've noticed that :

  • in my login page (with 1 secure UITextField), keyboard was AZERTY
  • in my signin page (with 2 secure UITextField), keyboards were QWERTY
  • in my account page (with 2 secure UITextField), keyboards were AZERTY

After a while of comparison between signin and account pages, I've realized that in my account page, the textfield before secure textfield was a .numberPad textfield.

So in my login xib file, I've set my secure textfields to .numberPad and I set them to .default in textFieldDidBeginEditing. And back to .numberPad again in textFieldDidEndEditing because if not, keyboards appeared in QWERTY the second time. Now, my secure textfields are in AZERTY.

func textFieldDidBeginEditing(_ textField: UITextField) {
    if ( textField == pwdTextField || textField == pwd2TextField ) {
        textField.keyboardType = .default;
    }
    // do other stuffs
}

func textFieldDidEndEditing(_ textField: UITextField) {
    if ( textField == pwdTextField || textField == pwd2TextField ) {
        textField.keyboardType = .numberPad;
    }
    // do other stuffs
}

@.@

This is because of the app default region setting. Remove below setting from info.plist.

<dict>
   <key>CFBundleDevelopmentRegion</key>
   <string>fr</string>
   ...
</dict>

Cheers...

Indeed, using 2 password content-type textfields (when the user has to confirm a new password for instance) creates issues with the keyboard. As stated here, the keyboard is set to QWERTY whereas it should be in AZERTY (with the language I use) and when I go from one textfield to the other, the keyboard blinks.

Actually, there's no need to set this content-type for password textfields, using "New password" content-type for both textfields works just fine and creates no issue with the keyboard.

Same Issue here: https://github.com/xlbs-rm/ios-demo

Filled a Bug Report here: https://feedbackassistant.apple.com/ Date 2020-07-31

No Reaction from Apple yet Issue on iOS 13.5.1, 13.7, 12.4.3 Issue on Connected Device (Debugging), Simulator, TestFlight Alpha Builds (for iTunesConnect Users), TestFlight Beta Builds (Apple Approved TestFlight Builds)

Only Solution is remove the 2nd Password Field!

Idea #2 textContentType = .oneTimeCode suggested here: https://stackoverflow.com/a/53760545

if #available(iOS 12.0, *) {
    tfPassword.textContentType = .oneTimeCode
}
  • not working
  • not removing the warning "Cannot show Automatic Strong Passwords for app..."

Idea #3 remove CFBundleDevelopmentRegion

  • not working

Idea #4 entend UITextField, override textInputMode return one with the correct lang similar to here: https://stackoverflow.com/a/52701639

  • not working

Solution:

if #available(iOS 12.0, *) {
    passInput.textContentType = .newPassword
}

Implement: UITextFieldDelegate

public func textFieldDidBeginEditing(_ textField: UITextField) {
    if exchangeResponder == false {
      exchangeResponder = true
      firstnameInput.becomeFirstResponder()
      textField.becomeFirstResponder()
      exchangeResponder = false
    }
}

passInput.delegate = self
pass2Input.delegate = self

Now I can move between all fields and have everytime the German keyboard!

Related