1

I have a very large HTML Document that I need to show in my app. It utilizes CSS Columns, and scrolls horizontally. What I try to do is archive the UIWebView that renders the document in its current state, so that I can unarchive it from CoreData and don't have to let the user wait for a few seconds until it's rendered. So inside my UIWebViewDelegate, I serialize using the following method when webViewDidFinishLoad is called (the content is loaded from string, not from external sources):

[NSKeyedArchiver archivedDataWithRootObject:self.webView];

I checked if webViewDidFinishLoad is called multiple times, but it isn't. This and the core data saving actually works, i.e. it does save and load properly the next time the app is launched. However, while it saves the UIWebView itself, it seems like the content isn't loaded into it, which makes the whole procedure kinda useless for my purpose. Is my understanding of saving an object this way wrong, or is it simply a question of implementation?

Many thanks!

LaK
  • 99
  • 1
  • 7
  • Does [this](http://stackoverflow.com/questions/1720524/iphone-uiwebview-download-complete-page-with-css-and-images?lq=1) help? – maroux May 03 '13 at 11:47
  • I'm afraid not, but thanks still. CSS Columns do not change the actual DOM structure of the HTML doc. I tried to actually do that and render the columns with jquery columnizer, but that was a drag and wouldn't even finish because it was way to resource-hungry... – LaK May 03 '13 at 11:57
  • Hi LaK, I wonder did you solve this? If yes - can you please post an answer here? – Aleksandr Nikiforov Mar 17 '14 at 19:45
  • I fear I couldn't solve it - at least rendering got faster in iOS 7 and using the faster processors of the new devices... but I'd be still interested in having a solution! – LaK Mar 18 '14 at 07:28

1 Answers1

0

I dont think you should be archiving the UIWebview. Instead you can save the html document fil with custom CSS elements in the documents directory of the app and render it using the filepath using the following code.

self.webview.scalesPageToFit=  YES;                        
[self.webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:filePath]]];
Xcoder
  • 1,762
  • 13
  • 17
  • Thanks for the answer, but I doubt that would solve my problem. What I want to do is spare the user the rendering time, the problem is not the actual html string, which is already saved in core data. It takes about 10 seconds to render the html, that's what should be eliminated after the first-time render. – LaK May 03 '13 at 11:51
  • May be because it takes lot of time to parse and render the page. Perhaps you could load the stuff in background and make it hidden(make it visible only when needed) Anyway I don think this is a proper solution. – Xcoder May 03 '13 at 12:02