我正在使用两个文本字段
password
和confirmPassword
我的 iCloud 钥匙串已打开。
@State private var email: String = ""
@State private var password: String = ""
@State private var passwordConfirmation: String = ""
var body: some View {
ScrollView {
VStack(spacing: 16) {
TextField("Email address", text: $email)
SecureField("Password", text: $password)
.textContentType(.password)
SecureField("Password confirmation", text: $passwordConfirmation)
.textContentType(.password)
}
.padding(.vertical, 32)
.padding(.horizontal, 16)
}
}
当我点击密码安全字段时,iOS 会向我显示强密码视图:
如果我使用此功能,一切正常,但如果我点击“其他选项...”,然后“选择我自己的密码”:
文本字段被清除(这很棒),但是如果我点击电子邮件文本字段(或任何其他文本字段),密码安全字段将填充我刚刚说过的我不想要的强密码...
这是一个视频:
我尝试了几种方法。
first.contentType = .newPassword and second.contentType = .password
或同时使用 .newPassword
但不起作用。
.textContentType(.none)
这将禁用自动填充