美文网首页
WebPageProxy::Ignoring request t

WebPageProxy::Ignoring request t

作者: paradisery | 来源:发表于2021-03-10 14:27 被阅读0次

在iOS13下,wkwebview在加载本地html后,点击跳转不在一个子文件夹下的html文件时,会报出WebPageProxy::Ignoring request to load this main resource because it is outside the sandbox。这个时候调用html,就不要用

NSString * path = [[NSBundle mainBundle] pathForResource:@"www/alert/index" ofType:@"html"];
NSString * request_url = [NSString stringWithFormat:@"file://%@",path];
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:request_url]];    
[self.webView loadRequest:request];

而是要用

NSString * path = [[NSBundle mainBundle] pathForResource:@"www/alert/index" ofType:@"html"];
NSString * request_url = [NSString stringWithFormat:@"file://%@",path];
NSString * wwwpath = [[NSBundle mainBundle] pathForResource:@"www" ofType:nil];
NSString * filepath = [NSString stringWithFormat:@"file://%@",wwwpath]; 
[self.webView loadFileURL:[NSURL URLWithString:request_url] allowingReadAccessToURL:[NSURL URLWithString:filepath]];

这个www文件路径就是你放本地html文件夹的路径。

相关文章

网友评论

      本文标题:WebPageProxy::Ignoring request t

      本文链接:https://www.haomeiwen.com/subject/jxewqltx.html