admin 管理员组文章数量: 1086019
If an element in a UIWebView has the style property -webkit-user-modify:read-write, then pressing on the element causes the keyboard to appear. Is it possible to bring up the keyboard programatically?
Thanks
If an element in a UIWebView has the style property -webkit-user-modify:read-write, then pressing on the element causes the keyboard to appear. Is it possible to bring up the keyboard programatically?
Thanks
Share Improve this question asked Mar 19, 2012 at 23:33 gary_zgary_z 651 silver badge9 bronze badges 1- Maybe apply that style to the body? – Chaosphere2112 Commented Mar 20, 2012 at 0:02
2 Answers
Reset to default 6It looks like in iOS6 now you can do this with "keyboardDisplayRequiresUserAction":
keyboardDisplayRequiresUserAction A Boolean value indicating whether web content can programmatically display the keyboard.
@property (nonatomic) BOOL keyboardDisplayRequiresUserAction Discussion When this property is set to YES, the user must explicitly tap the elements in the web view to display the keyboard (or other relevant input view) for that element. When set to NO, a focus event on an element causes the input view to be displayed and associated with that element automatically.
The default value for this property is YES.
Availability Available in iOS 6.0 and later. Declared In UIWebView.h
reference:
From iOS Developer Library:
Because the keyboard is displayed automatically when a view bees the first responder, you often do not need to do anything to display it. However, you can programmatically display the keyboard for an editable text view by calling that view’s beeFirstResponder method. Calling this method makes the target view the first responder and begins the editing process just as if the user had tapped on the view.
I doubt that calling [webView beeFirstResponder]
will bring up the keyboard as long as no HTML element with the required style has the focus. So your real problem might be to set the focus in your HTML document to an element programmatically. I would try to do this via Javascript. Something like this might work:
NSString *jscode = @"document.getElementById('whatever').focus();";
[self.webView stringByEvaluatingJavaScriptFromString:jscode];
本文标签: javascriptProgrammatically display keyboard in UIWebViewStack Overflow
版权声明:本文标题:javascript - Programmatically display keyboard in UIWebView - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744036789a2522514.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论