1. <tfoot id='ThcBp'></tfoot>
    <legend id='ThcBp'><style id='ThcBp'><dir id='ThcBp'><q id='ThcBp'></q></dir></style></legend>

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

      <bdo id='ThcBp'></bdo><ul id='ThcBp'></ul>

      <i id='ThcBp'><tr id='ThcBp'><dt id='ThcBp'><q id='ThcBp'><span id='ThcBp'><b id='ThcBp'><form id='ThcBp'><ins id='ThcBp'></ins><ul id='ThcBp'></ul><sub id='ThcBp'></sub></form><legend id='ThcBp'></legend><bdo id='ThcBp'><pre id='ThcBp'><center id='ThcBp'></center></pre></bdo></b><th id='ThcBp'></th></span></q></dt></tr></i><div id='ThcBp'><tfoot id='ThcBp'></tfoot><dl id='ThcBp'><fieldset id='ThcBp'></fieldset></dl></div>
    1. iOS - WKWebView 跨源请求仅支持 HTTP

      时间:2023-10-22
          <tbody id='n823m'></tbody>
        • <bdo id='n823m'></bdo><ul id='n823m'></ul>

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

          1. <legend id='n823m'><style id='n823m'><dir id='n823m'><q id='n823m'></q></dir></style></legend><tfoot id='n823m'></tfoot>

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

              • 本文介绍了iOS - WKWebView 跨源请求仅支持 HTTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                Hi i'm trying to load an html that is in the main Bundle with WKWebView this worked perfectly with UIWebView but now i have an error, the files in the html does not load send an error in the console : "XMLHttpRequest cannot load"

                this is an example http://proyectoshm.com/esferas/dosaguas/dosaguascitta.html of the content embedded.

                My code:

                let folder = "maquetas/esferas/(esfera)"
                
                let resourcePath = Bundle.main.resourcePath
                let subdir = URL(fileURLWithPath:resourcePath!).appendingPathComponent(folder, isDirectory: true)
                
                guard let path = Bundle.main.path(forResource: "index", ofType: "html", inDirectory: folder) else {
                    print("no se encontró path")
                    return
                
                }
                print(subdir.path)
                
                
                let url = NSURL.fileURL(withPath: path)
                 print(url.path)
                 vistaweb = WKWebView(frame: self.view.frame)
                
                vistaweb.loadFileURL(url, allowingReadAccessTo: subdir)
                
                self.view.addSubview(vistaweb)
                

                解决方案

                To resolve it, you need to turn allowFileAccessFromFileURLs on from WKPreferences

                Swift

                webView.configuration.preferences.setValue(true, forKey: "allowFileAccessFromFileURLs")
                

                Objective-C

                [webView.configuration.preferences setValue:@YES forKey:@"allowFileAccessFromFileURLs"];
                

                这篇关于iOS - WKWebView 跨源请求仅支持 HTTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何将本地 HTML 文件加载到 UIWebView? 下一篇:如何在表格单元格中使用 UIWebView?

                相关文章

              • <legend id='89ntm'><style id='89ntm'><dir id='89ntm'><q id='89ntm'></q></dir></style></legend>

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