xar*_*rly 10 objective-c ios wkwebview
我正在使用本地文件测试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];
}
Run Code Online (Sandbox Code Playgroud)
我从以下网址授予网址:
NSURL *presentationFolder = [self.presentationController url];
Run Code Online (Sandbox Code Playgroud)
没问题,因为我用UIWebview测试了相同的代码并且有效!
我总是得到同样的错误:
Could not create a sandbox extension for '/'
Run Code Online (Sandbox Code Playgroud)
这不起作用,我想它可以在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测试了相同的代码(临时文件夹),工作正常!
另外,我试过这个:
我可以发现,这是有效的,因为CSS和javascript嵌入在html中.
尝试XWebView,它有一个非常小的嵌入式 http 服务器。它比 GCDWebServer 小得多。通过扩展添加了一个loadFileURL:allowingReadAccessToURL方法,因此您不知道服务器。
| 归档时间: |
|
| 查看次数: |
9688 次 |
| 最近记录: |