设备 webKitView 不加载本地图像但模拟器加载图像

device webKitView not loading local images but simulator load the images

我有一个 html 文件位于设备的本地库目录中,一些图像位于同一目录中。因此,当我在模拟器中打开 webkitview 时,它会完美地加载图像,但是当我使用设备时,会加载 html 页面,但图像不是 loaded.this 是我的 html :

<html><head><script src='./test.js'></script></head><body><img src='./sample_attachment.jpg' alt='Girl in a jacket' /><body><html>

这就是我加载网络视图的方式:

            webView.loadFileURL(path, allowingReadAccessTo: path)

我还在 info.plist 中启用了允许任意加载。 感谢您的帮助!

我找到了可以帮助你们的解决方案: webView.loadFileURL(firstPath, allowingReadAccessTo: secondPath) 中的第一个路径是 html 文件的路径,第二个路径是允许您打开的资源的路径,我提出的问题相同这就是为什么只加载 html 页面的原因(我不知道为什么模拟器会正确加载资源)但是当我将目录的路径放在第二个路径中时它可以访问所有资源并完美加载它们.