在 UITextView 上设置 UITextContentType.emailAddress 无效

Setting UITextContentType.emailAddress on a UITextView is not working

我有一个 UITextView 是用 .emailAddress 的 UIKeyboardType 设置的 我想使用 UITextContentType 属性

自动建议用户的电子邮件地址

我是这样的:

if #available(iOS 10.0, *) {
                        myTextView.textContentType = UITextContentType.emailAddress
                    }

但是这不起作用,我在 textview 的建议框中看不到电子邮件。

我也用 UITextField 尝试过同样的事情,但没有骰子。 有什么我想念的吗?我已经根据文档完成了所有操作。

确保您已在“通讯录”应用中自己的名片中设置了您的电子邮件地址。

:)

如果是电子邮件地址,您还需要将 keyboardType 设置为 emailAddress。 我以为 prediction/autocomplete 在 iOS 13 上坏了,但你只需要指定正确的键盘类型。这就是我获取姓名和地址的方式:

textField.autocorrectionType = .yes
textField.textContentType = .givenName
textField.keyboardType = .namePhonePad