【发布时间】:2020-10-13 08:59:26
【问题描述】:
在我的 SwiftUI 项目中使用 TextField 视图时出现了一个奇怪的行为。
使用以下代码,TextField textContentType 设置为nil(或.none,或UITextContentType.init(rawValue: "")),但键盘会提示我一个OTP 代码(例如,如果最近收到的话在之前的视图中)。为什么?
我尝试了其他有效的 textContentType,例如 .name、.address、...但没有成功(只有 textContentType .password 和 .newPassword 禁用 OTP 建议)。
struct TestView: View {
@State private var text: String = ""
var body: some View {
TextField("", text: $text)
.keyboardType(.numberPad)
.textContentType(nil) // or .none, or UITextContentType.init(rawValue: "")
}
}
对于 UIKit 项目,UITextField 可以按预期工作(没有键盘建议)。有什么想法吗?
谢谢
【问题讨论】:
标签: textfield ios13 one-time-password swiftui