In one of our iOS / iPhone Apps we need to display the user's configured email addresses as suggestions during the registration process. There are several apps that display email addresses as fixed buttons within the input accessory view of the keyboard. The Yelp app for instance (iPhone 8 with iOS 13.4)
I could not figure out how enable this functionality with built-in means. I tried to set textContentType, keyboardType and autocorrectionType to the correct values as described in other stack overflow articles I could find about this topic.
This is my code
override func viewDidLoad() {
super.viewDidLoad()
let email = UITextField(frame: CGRect(x: 10, y: 60, width: 300, height: 40))
email.placeholder = "Enter email address here"
email.font = UIFont.systemFont(ofSize: 15)
email.borderStyle = UITextField.BorderStyle.roundedRect
email.clearButtonMode = UITextField.ViewMode.whileEditing
email.contentVerticalAlignment = UIControl.ContentVerticalAlignment.center
email.returnKeyType = .continue
email.keyboardType = .emailAddress
email.textContentType = .emailAddress
email.autocorrectionType = .yes
email.autocapitalizationType = .none
view.addSubview(email)
}
And this is how it looks like on the same iPhone 8 with iOS 13.4 as I was running the Yelp App on:
No email address suggestions.
The curious thing is that the same App running on my iPad shows suggestions but in a different way:
How can I display the user's email addresses in the same way as Yelp does it? Is there a special UITextField view I have to use or is there another way to get the email addresses and display them in a custom text accessory view?
Thanks for your help!