菜鸟教程小白 发表于 2022-12-12 09:32:42

ios - CSS 和 JS 文件未在 uiwebview 中加载


                                            <p><p>在我的应用程序中,一个包含在文件夹中的网站。我尝试使用以下代码在 webview 中加载它:</p>

<pre><code>self.wView.dataDetectorTypes = UIDataDetectorTypeLink;
NSString *htmlFile = [ pathForResource:@&#34;index&#34; ofType:@&#34;html&#34; inDirectory:NO];
    NSLog(@&#34;%@&#34;,htmlFile);
    //NSData *pathData = ;
    //NSString *htmlString = ;
    NSURL *url = relativeToURL: isDirectory:YES]];

    //(void);
    ] ;
</code></pre>

<p>我在 nslog 中获取文件路径。
但是在我的 webview 中,css 和 js 文件没有加载。</p>

<p>请帮助我。 </p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>这个问题的简单解决方案</p>

<p>在将网站文件夹复制到 XCode 时,只需选择选项<strong>为任何添加的文件夹创建文件夹引用</strong></p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - CSS 和 JS 文件未在 uiwebview 中加载,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/15331608/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/15331608/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - CSS 和 JS 文件未在 uiwebview 中加载