gpt4 book ai didi

html - WKWebView 无法为 '/' 创建沙箱扩展

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:01:57 24 4
gpt4 key购买 nike

我想使用外部文件 .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,我希望它只在一个 View 上工作,而不像 https://github.com/shazron/WKWebViewFIleUrlTest带有 2 个 View 和按钮的项目,我需要在页面中连接到互联网(阅读 iFrame)。

我该怎么办?

最佳答案

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

关于html - WKWebView 无法为 '/' 创建沙箱扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28989715/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com