在WKWebView——iOS Swift 4中设置键盘类型



如何在WKWebView中设置一个带有globe图标的键盘(语言更改选项(,以便在选择输入字段时,在webview中始终显示带globe的键盘。

您可以为文本输入元素配置一些键盘属性。例如,可以包括自动更正和自动资本化属性在输入元素的定义中指定键盘的行为,如以下示例所示。

<input type="text" size="30" autocorrect="off" autocapitalize="on">

您还可以控制当用户触摸网页中的文本字段。要显示电话键盘电子邮件键盘或URL键盘,使用电话、电子邮件或URL关键字分别用于输入元素上的type属性。显示数字键盘,将pattern属性的值设置为"[0-9]"或"\d"。

这些关键字和模式属性是HTML5的一部分在iOS中可用。以下列表显示了如何显示每种类型的键盘,包括标准键盘。

Text: <input type="text"></input>
Telephone: <input type="tel"></input>
URL: <input type="url"></input>
Email: <input type="email"></input>
Zip code: <input type="text" pattern="[0-9]*"></input>

更多参考:https://developer.apple.com/library/archive/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html#//apple_ref/doc/uid/TP40009542-CH5-w12

最新更新