简体   繁体   English

加载内容时更改UIWebView的颜色

[英]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). 我的应用程序中有一个UIWebView,它显示一些html格式的文本(从捆绑包中的.plist文件加载)。 The UIWebView takes about 1 second to render the text on the screen and during that second the whole UIWebView is white. UIWebView大约需要1秒钟才能在屏幕上呈现文本,在那一秒钟内,整个UIWebView都是白色的。 I have tried setting the backgronud color of the view to clear or black but that did not do anything. 我尝试将视图的背景色设置为clearblack但这没有任何作用。 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. 我还尝试使用委托方法仅在UIWebView进行didLoadContent时显示该UIWebView,但由于未涉及任何请求,因此从未调用该方法,我仅在此处呈现html字符串。

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? 如果没有,是否还有另一种方法可以在iPhone上呈现html文本?

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. 我不介意:将UIWebView的hidden属性设置为YES,显示一些调用选择器,以在2-3秒内将hidden属性更改为NO。

BTW do you mean you're loading a local HTML file? 顺便说一句,您是不是要加载本地HTML文件? 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? 您说过,此HTML是在“应用程序加载时”加载并显示的,我想这意味着启动而不是从某个位置加载其他数据? I'm also guessing the HTML is fully static hardcoded data, since you load it "offline" from .plist... 我还猜测HTML是完全静态的硬编码数据,因为您是从.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检查一次...我将视图隐藏起来,直到设置了该变量为止...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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