iOS 11 禁用密码自动填充附件 View 选项?

标签 ios swift ios11

截至目前,我想选择退出 iOS 11 提供的新选项,即在应用程序中建议密码。当我在 iOS 11 上运行该应用程序时,我会在键盘顶部看到自动填充选项,而我的用户名和密码文本字段甚至都没有显示。

所以,我的问题是,我怎样才能一起禁用新的密码自动填充功能,这样键盘上的按键就完全​​不显示,并且整体行为与 iOS 11 之前的版本相同?

enter image description here

最佳答案

iOS 11 & 12 & 13 - Swift 4.2 & 5(更新):

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: "")
}

iOS 11 解释:

确保像这样设置所有的 UITextField 对象。

例如,如果您有一个 UITextField 对象,用户必须在其中输入他的电子邮件地址,而另一个对象在其中,用户必须输入他的密码,将 UITextContentType("") 分配给它们的 textContentType 属性。否则它不会工作并且自动填充附件 View 仍会显示。

关于iOS 11 禁用密码自动填充附件 View 选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45452170/

相关文章:

swift - 使用 map 隐式展开可选的奇怪行为

ios - 如何在 drawRect 中获取 UIView 大小

ios - 从 AVPlayerViewController 中删除 Quicktime Logo

ios - 如何根据实例的属性更新 UILabel 的文本

iOS MKMapView 以用户位置为中心,然后在 Swift 3.0 中允许无限滚动

ios - React-Native:关闭/退出 React-Native View 回到 Native

ios - 核心数据 : annotation: Failed to load optimized model at path '/var/containers/Bundle/.... '

iOS 11 - 成为第一响应者不打开键盘

objective-c - 将字段中的值添加到 NSDictionary 时,我的应用程序崩溃

android - 通过 React Native 将 must-revalidate 与 NSURLSession 结合使用