UITextField 属性:键盘

UITextField attributes : keyboards

在 Xcode 的故事板中,我将键盘类型设置为电子邮件地址。我注意到还有一个 Content-Type(也可以有电子邮件地址内容类型)下拉列表。这样做的目的是什么?

screenshot

谢谢

根据文档:

The textContentType property is to provide the keyboard with extra information about the semantic intent of the text document.

另一方面,它们 keyboardType 属性 决定了将要显示的键盘布局。

键盘类型只设置要显示的键盘。

内容类型比较笼统。

UITextField 实现了 UITextInputTraits 协议。在此,Content Type 用于指示文本字段的语义。例如,它可用于指示可能发生的自动更正的种类。

有关此协议的更多详细信息,请参阅 https://developer.apple.com/documentation/uikit/uitextinputtraits