Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swift how to suggest user email in uitextfield as autocomplete

Rather than showing autocomplete words I would like to show the autocomplete of the user emails for example [email protected]

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

like image 731
user1898829 Avatar asked Oct 27 '25 10:10

user1898829


1 Answers

Set textContentType to emailAddress

let textField = UITextField()
textField.textContentType = .emailAddress
like image 143
Nikita Avatar answered Oct 30 '25 04:10

Nikita



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!