gpt4 book ai didi

swiftui - 在 SwiftUI View 中在 TextField 后面使用多个 SecureField 时的奇怪行为

转载 作者:行者123 更新时间:2023-12-03 19:00:56 24 4
gpt4 key购买 nike

注意:此错误已在 Xcode 13.0 beta 3 中修复
在 View 中跟随 TextField 时尝试使用多个 SecureField 时,我遇到了非常奇怪的行为。尝试在其中一个 SecureField 中输入文本会在一个字符处停止,该字段变为黄色并显示“强密码”,并在第二个 SecureField 中重复。这发生在 Xcode 12.2 中的 iOS 14.2 上的 Xcode 预览版和模拟器中。
这是一个演示该问题的最小示例:

struct SecureFieldTestView: View {

@State var displayName: String = ""
@State var password = ""
@State var passwordVerifiation = ""

var body: some View {
VStack {
TextField("Display name", text: $displayName)
SecureField("Password", text: $password)
SecureField("Verify Password", text: $passwordVerifiation)

}
.padding()
}
}

struct SecureFieldTestView_Previews: PreviewProvider {
static var previews: some View {
SecureFieldTestView()
}
}
simulator screenshot of issue
运行到模拟器时控制台显示以下错误:
[AutoFill] Cannot show Automatic Strong Passwords for app bundleID: <REDACTED BY ME> due to error: iCloud Keychain is disabled
[Assert] View <(null):0x0> does not conform to UITextInput protocol
我曾尝试将 SecureFields 包装到它们自己的 VStack{} 中并将它们全部包装到一个 Form{} 中,但问题仍然存在。
是否有明显我遗漏的东西,或者这是 SDK 中的一个错误?

最佳答案

我会向 Apple 报告有关此问题的错误...
但是,目前这里有一个解决方法来解决这个问题,并且仍然使用顶部没有黄色条的 SecureField..

SecureField("First", text: $password)
.textContentType(.newPassword)
只需为 newPassword 添加 textContentType ,该栏就不会出现。

关于swiftui - 在 SwiftUI View 中在 TextField 后面使用多个 SecureField 时的奇怪行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64839212/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com