Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...