Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After updating to iOS 13 suggestion(email, phone number, first name...) for UITextField don't appear above keyboard

Tags:

ios

swift

After updating device to iOS 13 input suggestion for inputField(UITextField). Like email, phone number, first name, last name don't appear above keyboard anymore. First image iOS 12.4.1 have suggested email, second image iOS 13.1.2 don't have any suggestion. Same demo app is build with xCode Version 11.0 (11A419c) on iPhone 7 iOS 12.4.1(first image, work as expected). iPhone 7 iOS 13.1.2(second image, don't have any suggestion above keyboard) I tested by adding textContentType in storyboard and also by adding next line in code directly

email.textContentType = .emailAddress

On iOS 12.4.1 everting working as expected

and

iOS 13.1.2 don't show suggestion

like image 508
Stefan Simic Avatar asked Oct 04 '19 12:10

Stefan Simic


People also ask

What is UITextField?

An object that displays an editable text area in your interface.


1 Answers

So for iOS 13 (or higher), I noticed that setting the following properties makes iPhone to suggest you all the data:

For email ensure all these three properties are set:

 emailField.autocorrectionType = .yes
 emailField.textContentType = .emailAddress
 emailField.keyboardType = .emailAddress

For first name and last name:

firstNameField.autocorrectionType = .yes
firstNameField.textContentType = .givenName
firstNameField.keyboardType = .namePhonePad

lastNameField.autocorrectionType = .yes
lastNameField.textContentType = .familyName
lastNameField.keyboardType = .namePhonePad

For phone number its a bit tricky:

phoneField.autocorrectionType = .yes
phoneField.textContentType = .telephoneNumber
phoneField.keyboardType = .numbersAndPunctuation

Also make sure that Predictive in Keyboards Setting of device is turned on. If it doesn't work at once turn it off wait for a few seconds and then turn on again and boom it would be working again.

Hope it helps!

like image 106
Sudhanshu Vohra Avatar answered Nov 09 '22 23:11

Sudhanshu Vohra