Search code examples
iosswift

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

and


Solution

  • 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!