WKWebView 无法为“/”创建沙箱扩展

WKWebView Could not create a sandbox extension for '/'

我想使用外部文件 .html 来使用 WKWebView。或者有没有没有外部文件的解决方案?在模拟器上一切正常,但在设备上却不行...

这是我的代码:

NSString *path = [[NSBundle mainBundle] pathForResource:@"myHTML" ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
WKWebViewConfiguration *theConfiguration =
[[WKWebViewConfiguration alloc] init];
[theConfiguration.userContentController
 addScriptMessageHandler:self name:@"interOp"];
_webView = [[WKWebView alloc] initWithFrame:self.view.frame
                                 configuration:theConfiguration];
[_webView loadRequest:request];
[self.view addSubview:_webView];

我读过这个主题:WKWebView not loading local files under iOS 8

我不想使用服务器。我正在使用 Objective-C,我希望它只在一个视图上工作,而不像 https://github.com/shazron/WKWebViewFIleUrlTest 项目有 2 个视图和按钮,我需要在页面中与互联网连接(阅读 iFrame) .

我该怎么办?

您必须将所有网络文件复制到应用程序的 NSTemporaryDirectory 并从那里调用您的 index.html。我在 iOS 8.3 上运行良好。