我将所有 html 嵌入到 WKWebView 中,直到我认识到 WKWebView 无法在本地加载 xml 文件之前一切正常
$.ajax({ 类型:“获取”, 网址:“tags.xml”, 数据类型:“xml”, 缓存:假, 成功:函数(xml){ }, 错误:函数(){ alert("处理 XML 文件时发生错误。"); } });
我的 UIWebView 代码
//urlFolder 位于本地一个临时文件中:tmp/www/htmlFolder //urlFile位于urlFolder:tmp/www/htmlFolder/index.html //xml文件位于urlFolder:tmp/www/htmlFolder/tags.xml WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init]; _webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:theConfiguration]; [_webView loadFileURL:urlFile allowedReadAccessToURL:urlFolder]; [self.view addSubview:_webView];
注意:我使用的是 XCode7.1 Beta、Objective-C、ios9.1、WKWebView