WebPageProxy::Ignoring request to load this main resource because it is outside the sandbox

在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文件夹的路径。

推荐阅读更多精彩内容