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

Ste*_*mic 7 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
Run Code Online (Sandbox Code Playgroud)

在iOS 12.4.1上,按预期工作

and

iOS 13.1.2不显示建议

Sud*_*hra 20

因此,对于 iOS 13(或更高版本),我注意到设置以下属性会使 iPhone 向您建议所有数据:

对于电子邮件,确保设置所有这三个属性:

 emailField.autocorrectionType = .yes
 emailField.textContentType = .emailAddress
 emailField.keyboardType = .emailAddress
Run Code Online (Sandbox Code Playgroud)

对于名字和姓氏:

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

lastNameField.autocorrectionType = .yes
lastNameField.textContentType = .familyName
lastNameField.keyboardType = .namePhonePad
Run Code Online (Sandbox Code Playgroud)

对于电话号码,它有点棘手:

phoneField.autocorrectionType = .yes
phoneField.textContentType = .telephoneNumber
phoneField.keyboardType = .numbersAndPunctuation
Run Code Online (Sandbox Code Playgroud)

另外,还要确保预测键盘设置装置被打开。如果它不立即工作,请关闭它,等待几秒钟,然后再次打开并繁荣它会再次工作。

希望能帮助到你!

  • 运行调试版本时,电话号码建议仍然对我不起作用 (2认同)