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

    1. <small id='2d0wY'></small><noframes id='2d0wY'>

        <tfoot id='2d0wY'></tfoot>
          <bdo id='2d0wY'></bdo><ul id='2d0wY'></ul>

      1. <legend id='2d0wY'><style id='2d0wY'><dir id='2d0wY'><q id='2d0wY'></q></dir></style></legend>

        允许 UIWebView 在没有 Internet 连接的情况下加载 http://localhost:port/pat

        时间:2023-10-22
        <tfoot id='bXC4A'></tfoot>

        • <small id='bXC4A'></small><noframes id='bXC4A'>

          <legend id='bXC4A'><style id='bXC4A'><dir id='bXC4A'><q id='bXC4A'></q></dir></style></legend>

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

                  本文介绍了允许 UIWebView 在没有 Internet 连接的情况下加载 http://localhost:port/path URI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在开发一个 iPad 应用程序,它有一个在高端口上侦听的嵌入式 HTTP 服务器,我正在使用 UIWebView 从这个 HTTP 服务器加载页面.

                  I am working on an iPad app which has an embedded HTTP server listening on a high port, and I am loading pages from this HTTP server using a UIWebView.

                  对于应用程序的功能,重要的是它在没有可用网络连接时工作.

                  For the functionality of the app, it is important that this works when no network connection is available.

                  UIWebView 正在加载格式为 http://localhost:port/path

                  当我在 iPad 上禁用 Wi-Fi 并运行应用程序时,UIWebView 的委托会收到带有以下 NSError 对象的 webView:didFailLoadWithError: 消息:

                  When I disable Wi-Fi on my iPad and run the application, the UIWebView’s delegate gets a webView:didFailLoadWithError: message with the following NSError object:

                  Error Domain=NSURLErrorDomain Code=-1009 UserInfo=0x1b4a50 "no Internet connection"
                  

                  很明显,SDK 很聪明,检测到它没有 Internet 连接,但应该可以在没有 Internet 连接的情况下访问 127.0.0.1/localhost/::1.我将向 Apple 报告此错误,但同时在此征求有关此 SDK 错误的可能解决方法的建议.

                  Clearly the SDK is being clever and detecting that it has no Internet connection, but it should be possible to access 127.0.0.1/localhost/::1 without an Internet connection. I will report the bug to Apple but am asking here for advice about possible workarounds for this SDK bug in the meantime.

                  请注意:更改应用程序的架构不在此问题的范围内.

                  Please note: changing the architecture of the application is not in scope for this question.

                  推荐答案

                  您可能想研究定义自己的方案并使用 NSURLProtocol 来实现它,而不是运行 HTTP 服务器.这将允许您在无需实现 HTTP 协议的情况下处理 URL 的加载,并且可以通过 SDK 解决此问题,如果您没有网络连接,则 HTTP 协议会提前失败.

                  You may want to investigate defining your own scheme and implementing it with NSURLProtocol instead of running an HTTP server. This will allow you to handle the loading of URLs without having to implement the HTTP protocol, and will get around this issue with the SDK where the HTTP protocol fails early if you have no network connection.

                  这篇关于允许 UIWebView 在没有 Internet 连接的情况下加载 http://localhost:port/path URI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:UIWebView 从后台返回后在 iOS 7 上更改 contentSize 下一篇:访问 UIWebView 的 JavaScriptCore 引擎

                  相关文章

                • <tfoot id='WdRh4'></tfoot>

                    • <bdo id='WdRh4'></bdo><ul id='WdRh4'></ul>
                    <legend id='WdRh4'><style id='WdRh4'><dir id='WdRh4'><q id='WdRh4'></q></dir></style></legend>

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

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