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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容