将密码自动填充到 UITextField 中

问题描述 投票:0回答:1

我想实现这样一个功能:一个密码UITextField,使用系统九宫格数字键盘(textField.keyboardType = .numberPad),并启用自动填充密码。像这样: 在此输入图片描述

这是我的代码:

       let passwordTextField: UITextField = {
           let textField = UITextField()
           textField.placeholder = "password"
           textField.textContentType = .password
           textField.isSecureTextEntry = true
           textField.keyboardType = .numberPad.
           return textField
       }()

当我设置

textField.isSecureTextEntry = true
时,自动填充密码按钮消失,如果设置
textField.isSecureTextEntry = false
,则自动填充密码按钮出现。

当我将

textField.keyboardType
设置为
.default
textField.isSecureTextEntry = true
等其他类型时,也会出现自动填充密码的按钮。

我想知道这是苹果的功能吗?有什么办法可以让

textField.isSecureTextEntry = true
textField.keyboardType = .numberPad
和自动填写密码按钮都出现吗?

ios swift objective-c uikit
1个回答
0
投票

您设置关联域名了吗?根据 Apple 开发人员文档 您必须有一些与您的应用程序关联的域才能具有自动填充功能。

当您的应用程序安装在 iOS 设备上时,系统会尝试 将应用程序与应用程序的关联中列出的所有域相关联 域名权利:

系统从关联域权利中获取每个域。

它尝试下载 Apple App Site Association 文件 (apple-app-site-association) 该域。

如果所有步骤都成功,系统会将应用程序与该应用程序关联 域,并为该域的凭据启用密码自动填充。

© www.soinside.com 2019 - 2024. All rights reserved.