swift how to suggest user email in uitextfield as autocomplete

我只是一个虾纸丫 提交于 2020-05-14 01:58:57

问题


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

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
    }()

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


回答1:


Set textContentType to emailAddress

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


来源:https://stackoverflow.com/questions/61169433/swift-how-to-suggest-user-email-in-uitextfield-as-autocomplete

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!