更新到iOS 13后,UITextField的建议(电子邮件,电话号码,名字...)不会出现在键盘上方


11

将设备更新到iOS 13后,为inputField(UITextField)输入建议。像电子邮件,电话号码,名字,姓氏都不再出现在键盘上方。第一个映像iOS 12.4.1建议使用电子邮件,第二个映像iOS 13.1.2没有建议。在iPhone 7 iOS 12.4.1上使用xCode版本11.0(11A419c)构建了相同的演示应用程序(第一张图片,按预期工作)。iPhone 7 iOS 13.1.2(第二张图片,键盘上方没有任何建议)我通过在故事板上添加textContentType以及直接在代码中添加下一行进行了测试

email.textContentType = .emailAddress

在iOS 12.4.1上,按预期工作

iOS 13.1.2不显示建议


Xcode版本?
拉里·克里希纳

Answers:


11

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

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

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

对于名字和姓氏:

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

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

对于电话号码来说有点棘手:

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

另外,还要确保预测键盘设置装置被打开。如果一次不起作用请将其关闭,等待几秒钟,然后再次打开,然后臂杆将再次起作用。

希望能帮助到你!


对于名称和电话号码,您可以将“ keyboardType”设置为“ .namePhonePad”
Neil
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.