swift how to suggest user email in uitextfield as autocomplete

Viewed 2836

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.

enter image description here

1 Answers

Set textContentType to emailAddress

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