问题
I'm trying to open a Webarchive stored in a Core Data database. The Core Database was created on a Mac and filled with some Webarchive by using a WebView. Now I want to display these WebArchives in the UIWebView in iOS. The problem is that I don't know how to do that.
In a similar post to this (here) Digital Robot said, that Webarchives are supported on iOS and I only have to load it from disk with a simple NSURLRequest into the UIWebView. The problem here is, that it doesn't get loaded - I only get a blank UIWebView.
Here is the code i tried :
NSURL *url = [NSURL fileURLWithPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"myWebarchive.webarchive"] isDirectory:false];
[((Website*)[self.websites objectAtIndex:[self.tableView indexPathForSelectedRow].row]).websiteData writeToURL:url atomically:true];
[webView loadRequest:[NSURLRequest requestWithURL:url]];
In the first line I'm creating an NSURL where the Webarchive will be written to from the database. In the second line I am getting the webarchive from the database and write it to the disk at the url. In the third line I'm loading the webarchive from disk into the WebView.
Can anybody point me into the right direction on how to load webarchives into a UIWebView?
来源:https://stackoverflow.com/questions/8378547/how-can-i-open-a-webarchive-in-a-uiwebview