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

前端 未结 4 1042
礼貌的吻别
礼貌的吻别 2020-12-19 12:03

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

相关标签:
4条回答
  • 2020-12-19 12:46

    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
    }
    

    @.@

    0 讨论(0)
  • 2020-12-19 12:50

    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!

    0 讨论(0)
  • 2020-12-19 12:52

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

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

    Cheers...

    0 讨论(0)
  • 2020-12-19 13:01

    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.

    0 讨论(0)
提交回复
热议问题