【发布时间】: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