我将所有html嵌入到WKWebView中,一直有效,直到我认识到WKWebView无法在本地加载xml文件
$.ajax({
type: "GET",
url: "tags.xml",
dataType: "xml",
cache: false,
success: function(xml) {
},
error: function() {
alert("An error occurred while processing XML file.");
}
});
我的UIWebView代码
//urlFolder is located locally in a temporary file: tmp/www/htmlFolder
//urlFile is located in the urlFolder: tmp/www/htmlFolder/index.html
//xml file is located in the urlFolder: tmp/www/htmlFolder/tags.xml
WKWebViewConfiguration *theConfiguration = [[WKWebViewConfiguration alloc] init];
_webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:theConfiguration];
[_webView loadFileURL:urlFile allowingReadAccessToURL:urlFolder];
[self.view addSubview:_webView];
注意:我使用的是XCode7.1 Beta,Objective-C,ios9.1,WKWebView