密码字段的键盘仅在 iOS 12 上从 azerty 切换到 qwerty(有时)

Que*_*Rth 5 keyboard textfield ios swift

我在 中编写了一个iOS应用程序Swift 4,我是法国人,所以我使用法语/法语地区的手机工作。

使用 iOS 12 设备,我的登录页面上的密码字段工作正常(使用保存的密码自动登录甚至可以工作,我没有做任何事情来使其正常工作),但在我的注册页面上,该字段使我的键盘从 AZERTY 切换到 QWERTY。

我的手机设置中只有 AZERTY 键盘,而且所有 iOS 12 设备都会发生这种情况,而不仅仅是我的...

我在代码中做的唯一一件事:(我的UIView文件名为 RegisterView.swift)

fieldPwd = UITextField()
fieldPwdConfirm = UITextField()
fieldPwd.isSecureTextEntry = true
fieldPwdConfirm.isSecureTextEntry = true
Run Code Online (Sandbox Code Playgroud)

这个问题有什么解决办法吗?谢谢 !

pyo*_*yon 2

我已经为我的项目找到了解决方案,也许它可以帮助某人。

我注意到:

  • 在我的登录页面(带有 1 secure UITextField),键盘是 AZERTY
  • 在我的登录页面(有 2 个安全UITextField)中,键盘是 QWERTY
  • 在我的帐户页面(有 2 个安全UITextField)中,键盘是 AZERTY

经过一段时间的登录页面和帐户页面的比较,我意识到在我的帐户页面中,安全文本字段之前的文本字段是一个.numberPad文本字段。

因此,在我的登录 xib 文件中,我将安全文本字段设置为.numberPad并将它们设置为.defaultin textFieldDidBeginEditing.numberPad再次回到textFieldDidEndEditing因为如果没有,键盘会第二次出现在 QWERTY 中。现在,我的安全文本字段位于 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
}
Run Code Online (Sandbox Code Playgroud)

@.@