How to set a custom keyboard for UIWebView

2019-04-26 07:01发布

How to show a custom keyboard and Input Accessory View for a editable UIWebView for iOS7 and up.

i.e: How can i set and make use a value from [UIWebView setInputView:] and [UIWebView setInputAccessoryView:]

3条回答
甜甜的少女心
2楼-- · 2019-04-26 07:18

It would be helpful to understand what you're trying to do? You can either be trying to force a specific type of keyboard such as numeric, email, etc. that will use the keyboard the user has explicitly installed on their device (or the system one).

In order to do this, you can reference this apple doc which shows you the 'type' attribute to add to an tag.

Otherwise you are asking about loading a custom keyboard that you have created from the webview. The app developer in me screams, "you should NEVER do this." If you're content is generic enough to merit putting into a webview, than it is certainly not worth loading a custom keyboard.

If you realllly need to do this, you can set keyboardDisplayRequiresUserAction to NO, then use custom javascript to request the app to perform a native function, then drop a uitextfield or uitextview directly overtop the html input field and set a custom input view on the native control. There are an obscene amount of problems with following this approach, and I sincerely hope you

查看更多
够拽才男人
3楼-- · 2019-04-26 07:28

Are you trying to customize the ios keyboard or you want to show an HTML keyboard?

In the first case you can look at this link: link

In the second case you can just google for it, this is the first result searching for "html keyboard".

Good luck

查看更多
唯我独甜
4楼-- · 2019-04-26 07:35

I believe there is no way to do this as of now. Hence, my current approach is to use a custom view below the keyboard and hide the keyboard and show the keyboard as required.

查看更多
登录 后发表回答