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

      iOS - WKWebView Cross origin requests are only supported for HTTP(iOS - WKWebView 跨源请求仅支持 HTTP)
          <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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
                Resume game cocos2d(恢复游戏 cocos2d)
                Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
                [ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)
                Storing and reading files from Documents directory iOS 5(从 Documents 目录存储和读取文件 iOS 5)
                How can I implement a virtual joystick for a cocos2d game outside the cocos2d environment?(如何在 cocos2d 环境之外实现 cocos2d 游戏的虚拟摇杆?)
                • <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>
                      <tbody id='89ntm'></tbody>
                  • <small id='89ntm'></small><noframes id='89ntm'>