• <legend id='UOEMt'><style id='UOEMt'><dir id='UOEMt'><q id='UOEMt'></q></dir></style></legend>

        <small id='UOEMt'></small><noframes id='UOEMt'>

        <i id='UOEMt'><tr id='UOEMt'><dt id='UOEMt'><q id='UOEMt'><span id='UOEMt'><b id='UOEMt'><form id='UOEMt'><ins id='UOEMt'></ins><ul id='UOEMt'></ul><sub id='UOEMt'></sub></form><legend id='UOEMt'></legend><bdo id='UOEMt'><pre id='UOEMt'><center id='UOEMt'></center></pre></bdo></b><th id='UOEMt'></th></span></q></dt></tr></i><div id='UOEMt'><tfoot id='UOEMt'></tfoot><dl id='UOEMt'><fieldset id='UOEMt'></fieldset></dl></div>
          <bdo id='UOEMt'></bdo><ul id='UOEMt'></ul>
        <tfoot id='UOEMt'></tfoot>
      1. 如何让 UIWebView 专注于表单输入并调出键盘?

        How can I get a UIWebView to focus on a form input and bring up the keyboard?(如何让 UIWebView 专注于表单输入并调出键盘?)

          <tfoot id='u0vW1'></tfoot>
            <bdo id='u0vW1'></bdo><ul id='u0vW1'></ul>

            1. <legend id='u0vW1'><style id='u0vW1'><dir id='u0vW1'><q id='u0vW1'></q></dir></style></legend>
                <i id='u0vW1'><tr id='u0vW1'><dt id='u0vW1'><q id='u0vW1'><span id='u0vW1'><b id='u0vW1'><form id='u0vW1'><ins id='u0vW1'></ins><ul id='u0vW1'></ul><sub id='u0vW1'></sub></form><legend id='u0vW1'></legend><bdo id='u0vW1'><pre id='u0vW1'><center id='u0vW1'></center></pre></bdo></b><th id='u0vW1'></th></span></q></dt></tr></i><div id='u0vW1'><tfoot id='u0vW1'></tfoot><dl id='u0vW1'><fieldset id='u0vW1'></fieldset></dl></div>
                  <tbody id='u0vW1'></tbody>

                  <small id='u0vW1'></small><noframes id='u0vW1'>

                  本文介绍了如何让 UIWebView 专注于表单输入并调出键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我创建了一个 UIWebView 用于登录 Facebook 的 Graph API OAuth 接口.这很好用,但我必须点击第一个输入字段才能弹出键盘.理想情况下,一旦表单出现,键盘就会出现.所以我一直在试图弄清楚如何让第一个表单字段从 webViewDidFinishLoad: UIWebViewDelegate 方法中获得焦点,如下所示:

                  I've created a UIWebView for logging into Facebook's Graph API OAuth interface. This works great, but I have to tap the first input field in order for the keyboard to pop up. Ideally, the keyboard would appear as soon as the form appears. So I've been trying to figure out how to make the first form field get the focus from the webViewDidFinishLoad: UIWebViewDelegate method, like so:

                  - (void)webViewDidFinishLoad:(UIWebView *)wv {
                      [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByName('email')[0].focus();"];
                  }
                  

                  唉,这行不通.奇怪的是,当我在 Firefox JavaScript 控制台中运行该 JavaScript 时,它确实将焦点移到了电子邮件字段.但是,当我在 Mac 的 Safari 中运行它时,它什么也不做,就像在 iOS 上一样.FWIW,alert(document.getElementsByName('email')[0]) 确实 表明它选择了一个 HTMLInputElement.那么为什么 focus() 在 iOS 或 Mac OS X 中什么都不做呢?

                  Alas, this does not work. Curiously, when I run that JavaScript in the Firefox JavaScript console, it does move the focus to the email field. When I run it in Safari for the Mac, however, it does nothing, just like on iOS. FWIW, alert(document.getElementsByName('email')[0]) does show that it selects an HTMLInputElement. So why does focus() do nothing either in iOS or Mac OS X?

                  推荐答案

                  现在这在 iOS 6 中成为可能.

                  This is now possible with iOS 6.

                  UIWebView* webView = <#your webView here#>;
                  [webView setKeyboardDisplayRequiresUserAction:NO];
                  [webView loadHTMLString:@"<html><head></head><body><form><input id="textField" /></form><script>document.getElementById("textField").focus();</script></body></html>"
                                  baseURL:nil];
                  

                  这篇关于如何让 UIWebView 专注于表单输入并调出键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pause youtube video, youtube api(暂停 youtube 视频,youtube api)
                  Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                  How can I stop a video with Javascript in Youtube?(如何在 Youtube 中停止使用 Javascript 的视频?)
                  How to call Greasemonkey#39;s GM_ functions from code that must run in the target page scope?(如何从必须在目标页面范围内运行的代码中调用 Greasemonkey 的 GM_ 函数?)
                  How do you mute an embedded Youtube player?(如何使嵌入式 Youtube 播放器静音?)
                  How to get number of video views with YouTube API?(如何使用 YouTube API 获取视频观看次数?)
                  <tfoot id='2M4Kl'></tfoot>
                • <legend id='2M4Kl'><style id='2M4Kl'><dir id='2M4Kl'><q id='2M4Kl'></q></dir></style></legend>

                          <tbody id='2M4Kl'></tbody>
                            <bdo id='2M4Kl'></bdo><ul id='2M4Kl'></ul>

                            <small id='2M4Kl'></small><noframes id='2M4Kl'>

                            <i id='2M4Kl'><tr id='2M4Kl'><dt id='2M4Kl'><q id='2M4Kl'><span id='2M4Kl'><b id='2M4Kl'><form id='2M4Kl'><ins id='2M4Kl'></ins><ul id='2M4Kl'></ul><sub id='2M4Kl'></sub></form><legend id='2M4Kl'></legend><bdo id='2M4Kl'><pre id='2M4Kl'><center id='2M4Kl'></center></pre></bdo></b><th id='2M4Kl'></th></span></q></dt></tr></i><div id='2M4Kl'><tfoot id='2M4Kl'></tfoot><dl id='2M4Kl'><fieldset id='2M4Kl'></fieldset></dl></div>