gpt4 book ai didi

swift - TextField .textContentType 修饰符在 SwiftUI 中无效

转载 作者:行者123 更新时间:2023-12-04 15:44:06 28 4
gpt4 key购买 nike

我有今天发布的最新 Xcode + MacOS。 textContentType 似乎不起作用。

TextField($binding, placeholder: placeholder,
onEditingChanged: { (changed) in
if changed { self.tapped = true }
else { self.tapped = false }}
).textContentType(.telephoneNumber)

最佳答案

行为与 UIKit 相同 UITextField用 Storyboard 制作(如果只设置了这个参数)。以下是 Apple 对此的说明:

When you provide this information about the content you expect users to enter in a text-entry area, the system can in some cases automatically select an appropriate keyboard and improve keyboard corrections and proactive integration with other text-entry opportunities.



将其视为提示,而不是规则。我总是和 .keyboardType 结合使用如下
TextField("", text: $phoneNumber)
.textContentType(.telephoneNumber)
.keyboardType(.phonePad)

关于swift - TextField .textContentType 修饰符在 SwiftUI 中无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56639020/

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