iOS TextField 强密码自动填充,即使我们不想要它

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

我正在使用两个文本字段

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
但不起作用。

错误参考:https://developer.apple.com/forums/thread/716589

ios swiftui autofill securefield
1个回答
0
投票
.textContentType(.none)

这将禁用自动填充

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