【问题标题】:WKWebView Could not create a sandbox extension for '/'WKWebView 无法为“/”创建沙盒扩展
【发布时间】:2015-03-11 14:45:39
【问题描述】:

我想使用外部文件 .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)。

我该怎么办?

【问题讨论】:

    标签: html ios objective-c uiwebview wkwebview


    【解决方案1】:

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-28
    • 2017-12-11
    • 2013-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-22
    • 2021-11-20
    相关资源
    最近更新 更多