UIWebView serialization after content has been rendered
Asked Answered
H

1

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!

Hemphill answered 3/5, 2013 at 11:32 Comment(4)
Does this help?Workhorse
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...Hemphill
Hi LaK, I wonder did you solve this? If yes - can you please post an answer here?Zenda
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!Hemphill
B
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]]];
Branchiopod answered 3/5, 2013 at 11:41 Comment(2)
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.Hemphill
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.Branchiopod

© 2022 - 2024 — McMap. All rights reserved.