迅速如何在uitextfield中建议用户电子邮件自动完成 [英] swift how to suggest user email in uitextfield as autocomplete

查看:115
本文介绍了迅速如何在uitextfield中建议用户电子邮件自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想显示自动填充字词,而是想显示用户电子邮件的自动填充字词,例如example@domain.com

Rather than showing autocomplete words I would like to show the autocomplete of the user emails for example example@domain.com

如果我转到 https://www.superbru.com/beta/register,则会发生这种情况.php 在Safari中,我会在自动填充框中找到我建议的电子邮件地址.

This happens if I go to https://www.superbru.com/beta/register.php in Safari I get my email address suggested to me in the autocomplete box.

这是我设置文本字段的方式,但是仍然没有电子邮件提示.

This is how I set up my textfield but still no email being suggested.

 private let emailTextField: UITextField = {
    let textField = UITextField()
       textField.height(equalTo: 45)
       textField.keyboardType = .emailAddress
       textField.returnKeyType = .done
       textField.placeholder = "E-mail"
       textField.addTarget(self, action: #selector(textFieldTextDidChange), for: .editingChanged)
        return textField
    }()

并设置autocorrectionType = .default或yes也不起作用.

and setting autocorrectionType = .default or yes does not work either.

推荐答案

将textContentType设置为emailAddress

Set textContentType to emailAddress

let textField = UITextField()
textField.textContentType = .emailAddress

这篇关于迅速如何在uitextfield中建议用户电子邮件自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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