iOS 12 OTP 键盘建议 [英] iOS 12 OTP keyboard suggestion

查看:124
本文介绍了iOS 12 OTP 键盘建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一次性代码从 SMS 传输到键盘上方的字段,如图所示.

但由于某种原因,键盘上方的字段没有显示.

代码:self.valueTextField.textContentType = UITextContentTypeOneTimeCode;

界面层次结构:

+UIView

  • 自定义内容视图
  • UIImageView
  • UITextField - valueTextField
  • UITextFieldContentView

我已阅读以下材料:在第一条消息中,我们的代码被系统定义为电话号码.如果我们点击它,我们甚至可以调用它.但是为什么我们需要调用一次性代码呢?:)

在第二张图中,代码被定义为一次性的,正是我们所需要的.如果我们点击它,系统会提示将其复制到剪贴板.

有什么区别?不幸的是,在 SMS 中解析文本的规则并不完全清楚.但我们可以通过以下方式检查您的文本:

如果您为文本字段设置了属性 textContentType 并且没有任何效果,您需要检查的第一件事是操作系统是否正确确定了代码.为此,只需转到消息应用程序并检查代码:

  1. 带下划线的蓝色字体颜色 - 系统无法识别一次性代码.
  2. 带有灰色下划线的黑色字体颜色(默认) - 没问题!

最后,在第一种情况下,您应该检查消息文本中是否有错误字符的内容.

PS 只是几个正确和错误短信的例子:

  • 短信代码:12345 £ 正确
  • 短信代码:12345 $ 正确
  • 短信代码:12345 № 正确
  • 短信代码№1:12345不正确

I'm trying to implement the transfer of a one-time code from SMS to the field above the keyboard, as in the image.

But for some reason the field above the keyboard is not displayed.

Code:self.valueTextField.textContentType = UITextContentTypeOneTimeCode;

UI hierarchy:

+UIView

  • CustomContentView
  • UIImageView
  • UITextField - valueTextField
  • UITextFieldContentView

I have read these materials:soQuestion and apple docs , and I saw a warning:

If you use a custom input view for a security code input text field, iOS cannot display the necessary AutoFill UI.

... but I do not understand what is meant by custom input view.

Also I have category for UITextField. Can it affect the work?

I will be glad to any ideas, thanks!

解决方案

Okay. This is what I could find out. Regarding the code, it is enough that I described above. Additional settings on the client is not required. But you need to pay attention to the text of the SMS message. As an example, I attached two messages.

In the first message, our code is defined by the system as a phone number. We can even call it if we click on it. But why do we need to call a one-time code? :)

In the second image, the code is defined as one-time, just what we need. If we click on it, the system will offer to copy it to the clipboard.

What is the difference? Unfortunately, it is not completely clear by what rule the text is parsed in SMS. But we can check your text in the following way:

If you set a property textContentType to your text field and nothing works for you, the first thing you need to check is whether the operating system determines the code correctly. To do this, simply go to the message application and check the code:

  1. blue font color with underscore - the system did not recognize one-time code.
  2. black font color (as default) with a gray underscore - it's okay!

At the end, in the first case, you should check the text of the message for the contents of incorrect characters.

PS Just a couple of examples of correct and incorrect SMS:

  • SMS-code: 12345 £ correct
  • SMS-code: 12345 $ correct
  • SMS-code: 12345 № correct
  • SMS-code №1: 12345 incorrect

这篇关于iOS 12 OTP 键盘建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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