我正在使用本地文件测试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中.