简体   繁体   中英

Change UIWebView's color while loading content

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.

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.

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.

我在我的应用程序中使用一个JavaScript变量来处理此问题,该变量每隔0.5秒就会触发一次NSTimer检查一次...我将视图隐藏起来,直到设置了该变量为止...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM