问题
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