ios - Xcode 6 Swift WKWebView 键盘设置

标签 ios swift

我正在使用 WKWebView 加载网站,一切正常。但是,我无法像使用文本字段那样访问键盘属性。有人能给我指点一些资源,帮助我访问网络上键盘的属性(通过图形用户界面或编程方式)吗?

最佳答案

Text Programming Guide for iOS , 有一个名为 Configuring the Keyboard for Web Views 的部分声明如下:

Although the UIWebView class does not support the UITextInputTraits protocol directly, you can configure some keyboard attributes for text input elements. For example, you can include autocorrect and autocapitalize attributes in the definition of an input element to specify the keyboard’s behaviors, as shown in the following example.

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

You can also control which type of keyboard is displayed when a user touches a text field in a web page. To display a telephone keypad, an email keyboard, or a URL keyboard, use the tel, email, or url keywords for the type attribute on an input element, respectively. To display a numeric keyboard, set the value of the pattern attribute to "[0-9]*" or "\d*".

These keywords and the pattern attribute are part of HTML 5 and are available in iOS. The following list shows how to display each type of keyboard, including the standard keyboard.

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>

当然,这只能在有限的情况下解决一些非常具体的问题,但据我所知,即使是 WKWebView,我们也只能解决这些问题了。 .

我希望有人能证明我是错的,并让我们知道如何添加键盘附件 View ,或者在 iOS 应用程序中将焦点放在 Web View 内的表单元素上时更改键盘的外观。

关于ios - Xcode 6 Swift WKWebView 键盘设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26872450/

相关文章:

ios - 给视频加水印特别慢

ios - 搜索时打开AnnotationView

ios - 无法使用 swift 2 在 IOS9 上的 webview 中加载 http 授权网站 url

ios - 我使用 NSAttributedString 还是 UIWebView Swift

iphone - 我可以创建一个包含类、xib 和图像的框架并将其用作另一个项目的框架吗?

ios - redirect_uri_mismatch iOS上的Unity Google API

ios - 将宏名称与NSString连接

ios - NSString isEqualToString 不工作

swift - 返回确认协议(protocol)的结构类型

ios - swift 5 - xcode 10.2 更新问题。收到很多警告