如何解决禁用自动更正类型不适用于 UITextfield
我已经用电子邮件、密码和确认密码字段创建了 RegisterViewController
。
在电子邮件字段中,它总是在 QuickType 的键盘栏上显示建议电子邮件,但其他字段不显示任何内容。
它如何知道哪个字段是电子邮件?我发誓我没有为文本字段设置任何内容。
我已经在我的基类文本字段上设置了 autocorrectionType = .no
,但它仍然在栏上显示建议。
有人可以帮我解决这个问题吗?
解决方法
试试textField.textContentType = .none
这不是自动更正。这是建议
使用以下代码禁用建议
if #available(iOS 12,*) {
// iOS 12 & 13: Not the best solution,but it works.
passwordTextField.textContentType = .oneTimeCode
} else {
// iOS 11: Disables the autofill accessory view.
// For more information see the explanation below.
emailTextField.textContentType = .init(rawValue: "")
passwordTextField.textContentType = .init(rawValue: "")
}
,
你可以试试这个:
textField.disableAutocorrection(true)
textField.disableAutocorrection(false)
或者这个:
textField.autocorrectionType = .yes
textField.autocorrectionType = .no
要隐藏栏(预测栏),请使用以下代码:
if #available(iOS 9.0,*) {
var item = textFeild.inputAssistantItem
item.leadingBarButtonGroups = [];
item.trailingBarButtonGroups = [];
}
这也可能对您有所帮助:
self.passwordField.isSecureTextEntry = true
if #available(iOS 11.0,*) {
self.emailField.textContentType = .username
self.emailField.keyboardType = .default
}
if #available(iOS 12.0,*) {
self.passwordField.textContentType = .password
self.passwordField.keyboardType = .default
}
,
您可以尝试以下方法 -
textField.autocapitalizationType = .none
textField.autocorrectionType = .no
textField.spellCheckingType = .no
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。