Shortcuts or autofill for contact info in UITextFields
One note, if you have email and password on a screen, sometimes the native keychain detection overrides textContentType=email so autofill using textContentType stops working for the email field. For things like "create account" where they don't likely have existing credentials in keychain it's best to disable the keychain. To fix this
To disable keychain, just do this: passwordTextField.textContentType = @"";
Then email autofill should work again:
emailTextField.textContentType = UITextContentTypeEmail;
For iOS 13, I've found that email suggestions are only enabled if you set all 3 of the following properties:
emailTextField.textContentType = .emailAddress
emailTextField.keyboardType = .emailAddress
emailTextField.autocorrectionType = .yes
You can do it programatically or via storyboard.
You can turn on or off it by set autocorrectionType
of UITextField
. Default value of autocorrectionType
is UITextAutocorrectionTypeDefault
. It means you don't need to do anything, by default it will be showed.
UITextAutocorrectionTypeYes; // Turn on
UITextAutocorrectionTypeDefault; // Turn on
UITextAutocorrectionTypeNo; // Turn off
But beside of set autocorrectionType
value, you need to make sure Predictive
in Keyboards Setting
of device is turned on. If Predictive
is turned off, suggestion won't be displayed even you changed autocorrectionType
to UITextAutocorrectionTypeYes
.
UPDATE
You can change textContentType
to choose with type of suggestion will be shown. Suggestions are from the Contacts
. For example, you want phone suggestion
textField.textContentType = UITextContentTypeTelephoneNumber;