How can I open a WebArchive in a UIWebView?

安稳与你 提交于 2019-12-22 18:36:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!