WKWebView与本地文件

 我爱宝宝们小童鞋_244_571_742 发布于 2022-12-08 18:33

我正在使用本地文件测试WKWebView,该文件在模拟器中工作,但它在设备中不起作用

 @interface EDPresentationViewController ()


     @property(nonatomic,strong)WKWebView *webView;

     @property(nonatomic,strong)EDPresentationController *presentationController;

 @end


@implementation EDPresentationViewController

-(void)viewDidLoad
{
    [super viewDidLoad];

    self.presentationController = [[EDPresentationController alloc]init];

    WKWebViewConfiguration *webConfiguration = [[WKWebViewConfiguration alloc]init];
    self.webView = [[WKWebView alloc]initWithFrame:self.view.frame configuration:webConfiguration];

    NSURL *presentationFolder = [self.presentationController url];
    NSURLRequest *request = [NSURLRequest requestWithURL:presentationFolder];

    [self.webView loadRequest:request];
}

我从以下网址授予网址:

    NSURL *presentationFolder = [self.presentationController url];

没问题,因为我用UIWebview测试了相同的代码并且有效!

我总是得到同样的错误:

Could not create a sandbox extension for '/'

这不起作用,我想它可以在Objective-C中工作,就像在swift中一样

iOS Webkit不在设备上工作,但在swift的模拟器上运行

任何想法将不胜感激,谢谢


更新2-12-2014

我发现这可能是iOS 8.1中的一个错误,可能会在8.2中修复

https://devforums.apple.com/thread/247777?start=25&tstart=0

我已经测试过将文件移动到临时文件夹,但我没有收到任何错误,但webView只是空的.

我用UIWebView测试了相同的代码(临时文件夹),工作正常!

另外,我试过这个:

/sf/ask/17360801/

我可以发现,这是有效的,因为CSS和javascript嵌入在html中.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有