如何启用/禁用特定文本字段的OneTimeCode功能? [英] How to enable/disable OneTimeCode feature for specific text field?

查看:57
本文介绍了如何启用/禁用特定文本字段的OneTimeCode功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于OTP文本字段,我已将textContentType设置为oneTimeCode

For OTP text field, I have set textContentType as oneTimeCode

if #available(iOS 12.0, *) {
     otpTextField.textContentType = .oneTimeCode
}    

现在,当我们收到OTP时,iOS将显示所有键盘类型设置为numberPad的文本字段的OTP,例如安全令牌,邮政编码等.

Now when we receive OTP, iOS is showing OTP for all text fields for which keyboard type is set as numberPad e.g) Security Token, zipcode etc.

对于应用程序中所有文本字段的文本内容类型为oneTimeCode的文本字段,应用程序仅应填充OTP.

The app should only populate OTP for text field that has textContentType as oneTimeCode not for all text fields in the app.

如何为特定的文本字段启用/禁用oneTimeCode?

How to enable/disable oneTimeCode for specific text field?

推荐答案

我尝试了各种内容类型,以防止在键盘上建议使用OTP,最后这一方法奏效了

I tried all sorts of content types to prevent OTP from being suggested on the keyboard, finally this one worked

if #available(iOS 12.0, *) {
    textField.textContentType = .username
}

在这种情况下,UITextField正在捕获图钉,并且还具有

In this case the UITextField is capturing a pin, and also has

keyboardType = .numberPad

尽管可能没有什么不同

这篇关于如何启用/禁用特定文本字段的OneTimeCode功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆