我正在使用本地文件测试 WKWebView,该文件在模拟器中工作,但在设备中不起作用
@interface EDPresentationViewController ()<WKNavigationDelegate,WKScriptMessageHandler>
@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 模拟器上运行 https://stackoverflow.com/questions/25973319/ios-webkit-not-working-on-device-but-works-on-simulator-at-swift
任何想法将不胜感激,谢谢
更新 2-12-2014
我发现这可能是 iOS 8.1 中的一个错误,并且可能在 8.2 中修复
我已经测试过将文件移动到临时文件夹,没有收到任何错误,但 webView 是空的。
我已经使用 UIWebView 测试了相同的代码(临时文件夹)并且工作正常!
另外,我已经尝试过这个:
https://stackoverflow.com/a/26054170/426180 https://stackoverflow.com/a/26054170/426180
据我所知,这是有效的,因为 css 和 javascript 嵌入在 html 中。