Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autofill for UITextField is broken

In my sign up form in my app, the keyboard suggests an entry for my first name, last name, eventually a strong password, but not for my email address. I have content-type set to email in the storyboard and in code:

enter image description here

self.emailTxt.textContentType = .emailAddress

But no suggestion. You can see in the image below, the keyboard suggests the first and last name of the user, but for email it is blank. enter image description here

In the next image I show that in signing up for sites on safari, it does suggest my email. Even moreso, it suggests to autofill the entire page:enter image description here

What could I be missing?

EDIT: I created a github repo demonstrating the error. Every field should be auto-filled. What I am experiencing is that in this app, the email works but password doesn't suggest to create a new password. Nothing is working together.

like image 565
Code Wiget Avatar asked Sep 06 '25 06:09

Code Wiget


1 Answers

So, the issue in general was that apple's autofill was having a difficult time determining if I was creating an account. From their documentation here:

By default, the system selects the a keyboard based on the input view’s textContentType property; however, you can mix the input view’s text content type and keyboard type to explicitly define the desired keyboard. For example, if your site uses email addresses as user names, set the input view’s textContentType property to .username, and set the keyboardType property to .UIKeyboardType.emailAddress.

So, for the email address I set the content type to username and the keyboard type to email, and all is fixed.

like image 103
Code Wiget Avatar answered Sep 10 '25 14:09

Code Wiget