Setting UITextContentType.emailAddress on a UITextView is not working

Viewed 2468

I have a UITextView which is set with UIKeyboardType of .emailAddress I want to auto-suggest the user's email address with the UITextContentType property

I do so like so:

if #available(iOS 10.0, *) {
                        myTextView.textContentType = UITextContentType.emailAddress
                    }

However this is not working and I see no email in the suggestion box of the textview.

I have also tried the same thing with a UITextField but no dice. Is there something I am missing? I have done everything according to the docs. enter image description here

2 Answers

Make sure you have set your email address in your own Contact card in the Contacts app.

:)

In case of email addresses you need to set your keyboardType to emailAddress also. I thought prediction/autocomplete is broken on iOS 13 but you just need to specify the right type of keyboard. This is how I got names and addresses to work:

textField.autocorrectionType = .yes
textField.textContentType = .givenName
textField.keyboardType = .namePhonePad
Related