title: iOS / Swift: Showing email addresses suggestions on keyboard for UITextFields
body: <p>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)</p>
  
  <p><a href="https://i.stack.imgur.com/LWKIb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LWKIb.png" alt="Yelp on iPhone 8 running iOS 13.4"></a></p>
  
  <p>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.</p>
  
  <p>This is my code</p>
  
  <pre><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)
  }
  </code></pre>
  
  <p>And this is how it looks like on the same iPhone 8 with iOS 13.4 as I was running the Yelp App on:</p>
  
  <p><a href="https://i.stack.imgur.com/370IG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/370IG.png" alt="Test App on the same iPhone 8 running iOS 13.4"></a></p>
  
  <p>No email address suggestions.</p>
  
  <p>The curious thing is that the same App running on my iPad shows suggestions but in a different way:</p>
  
  <p><a href="https://i.stack.imgur.com/aebIA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aebIA.png" alt="Test App on iPad Pro running iOS 13.3"></a></p>
  
  <p>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?</p>
  
  <p>Thanks for your help!</p>