views:

428

answers:

3

I have a UIWebView in my app that shows some html-formatted text (loaded from a .plist file from my bundle). The UIWebView takes about 1 second to render the text on the screen and during that second the whole UIWebView is white. I have tried setting the backgronud color of the view to clear or black but that did not do anything. I also tried using the delegate methods to show the UIWebView only when it didLoadContent but that method is never called since there us no request involved, I'm only rendering an html string there.

Is there a way to show nothing until the view is rendered?

If not, is there another way to render html-text on an iPhone?

Thank you.

A: 

Off the top of my mind: Set the UIWebView's hidden property to YES, display something call a selector to change the hidden property to NO in 2-3 seconds.

BTW do you mean you're loading a local HTML file? Or is the delay created by downloading the file?

~ Natanavra.

natanavra
Nothing is loaded. The html is written in an `NSString` like `@"<html><body>...</body></html>"`.The selector approach will not work for me, because this html text is what is displayed while the app loads. So it stays on the screen only for a few seconds. Thus:1. I want it to appear as soon as it is loaded.2. I don't want a selector to fire too late when my whole UIViewController has been de-allocated.
Dimitris
A: 

You said this HTML was loaded and presented "while app loads" which I guess means starting up instead of loading some other data from somewhere? I'm also guessing the HTML is fully static hardcoded data, since you load it "offline" from .plist...

Suggestion: why don't you take a screenshot of the ready-rendered page, save that inside your app and display during app startup? Should be faster.

JOM
It's offline data but it has to be dynamic. I have 20 different HTMLs in a plist and I want to render a random one every time. What I did in the end, was have 20 images (the rendered thing) and load those instead (so, what you suggested above more or less)...
Dimitris
A: 

I handle this in my app with a javascript variable that I check with a NSTimer that is fired every 0.5 seconds... I leave the view hidden until that variable is set...

Jay Van Vark