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

Password field#39;s keyboard switches from azerty to qwerty (sometimes) only on iOS 12(密码字段的键盘仅在 iOS 12 上从 azerty 切换到 qwerty(有时))
本文介绍了密码字段的键盘仅在 iOS 12 上从 azerty 切换到 qwerty(有时)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

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

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

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

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.

我的手机设置中只有 AZERTY 键盘,它发生在所有 iOS 12 设备上,而不仅仅是我的...

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

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

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 !

推荐答案

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

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

我注意到了:

  • 在我的登录页面(带有 1 个安全 UITextField)中,键盘是 AZERTY
  • 在我的登录页面(带有 2 个安全 UITextField)中,键盘是 QWERTY
  • 在我的帐户页面(带有 2 个安全 UITextField)中,键盘是 AZERTY
  • 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

在对登录页面和帐户页面进行了一段时间比较之后,我意识到在我的帐户页面中,安全文本字段之前的文本字段是 .numberPad 文本字段.

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.

所以在我的登录 xib 文件中,我已将安全文本字段设置为 .numberPad 并在 textFieldDidBeginEditing 中将它们设置为 .default.并在 textFieldDidEndEditing 中再次返回 .numberPad,因为如果没有,键盘会第二次出现在 QWERTY 中.现在,我的安全文本字段位于 AZERTY 中.

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
}

@.@

这篇关于密码字段的键盘仅在 iOS 12 上从 azerty 切换到 qwerty(有时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

No resource found that matches the given name: attr #39;android:keyboardNavigationCluster#39;. when updating to Support Library 26.0.0(找不到与给定名称匹配的资源:attr android:keyboardNavigationCluster.更新到支持库 26.0.0 时) - IT屋-程序员软
How to resize UITextView on iOS when a keyboard appears?(出现键盘时如何在iOS上调整UITextView的大小?)
How to reliably detect if an external keyboard is connected on iOS 9?(如何可靠地检测 iOS 9 上是否连接了外部键盘?)
How to mimic Keyboard animation on iOS 7 to add quot;Donequot; button to numeric keyboard?(如何在 iOS 7 上模拟键盘动画以添加“完成数字键盘的按钮?)
How do I dismiss the iOS keyboard?(如何关闭 iOS 键盘?)
Is possible to simulate touch event using an external keyboard on ios jailbroken?(是否可以在 ios 越狱后使用外部键盘模拟触摸事件?)