Show keyboard automatically with focus() event in UIWebView using Trigger.IO/PhoneGap

☆樱花仙子☆ 提交于 2019-12-19 04:15:16

问题


Supposedly, this has not been possible since iOS 6 where you can set the UIWebView's keyboardDisplayRequiresUserAction = NO.

I'm using a html 5 webview (Trigger.IO) and building a native plugin but am having difficulty grabbing hold of the UIWebView instance.

How do I grab hold of the webview so I can simply do the following:

mywebview.keyboardDisplayRequiresUserAction = NO;

Probably really simple.. what am I missing?


回答1:


Access to the UIWebView isn't something we properly expose in the current version of plugins (but is something we will support soon). For now if you want to try it out you can add

extern UIWebView *webView;

to the top of your plugin file, which will make the variable webView available in your API methods. This will stop working very soon though so I recommend you only use this to test things out for now.

Update Oct 2012:

The app's web view is now exposed via ForgeApp: http://docs.trigger.io/en/v1.4/_static/native/ios/Classes/ForgeApp.html#//api/name/webView

E.g.:

[ForgeApp sharedApp].webView



回答2:


As describec here, you can now add the property

KeyboardDisplayRequiresUserAction=NO;

to your Cordova.plist file and then just call

$(el).focus();


来源:https://stackoverflow.com/questions/13002376/show-keyboard-automatically-with-focus-event-in-uiwebview-using-trigger-io-pho

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!