我正在尝试构建一个原生应用程序,该应用程序的所有意图和目的都是 HTML/CSS 和 Javascript.一切正常,但是当 UIWebView 加载时,在填充 DOM、检索图像等时会有延迟.
I'm trying to build a native application that for all intents and purposes is HTML/CSS and Javascript. It all works fine, but when the UIWebView loads there's a delay while the DOM is populated, images retrieved etc.
到底有没有在 UIWebView 上显示背景图像,或者它背后的东西?理想情况下,这将与初始屏幕相同,因此不会影响从斜线过渡到应用的体验.
Is there anyway to display a background image on the UIWebView, or something behind it? Ideally this will be the same as the splash screen so it doesn't affect the experience of transitioning from slash to app.
谢谢
罗比
我不相信你想将 UIWebView 设置为透明并在其后面显示图像.
I don't believe you want to be setting the UIWebView as transparent and showing an image behind it.
相反,在 UIWebView 加载其内容之前,您应该有某种视图(可能带有您建议的图片,可能带有 UIIndicator 和使页面变暗"的半透明视图).
Instead you should have some sort of view (maybe with a picture as you suggest, maybe with a UIIndicator and a semi-transparent view that "darkens" the page) that sits there until the UIWebView has loaded its content.
为此,首先你的类应该订阅 UIWebViewDelegate 协议:
To do this, first your class should subscribe to the UIWebViewDelegate protocol:
@interface myWebView : UIViewController <UIWebViewDelegate> {
// variables etc
}
然后,您可以在加载时显示视图:
Then, you can show a view on load:
-(void)viewDidLoad {
myView.hidden = NO;
}
最后,您可以覆盖 webViewDidFinishLoad 方法以在加载后将其隐藏
And finally, you can override the webViewDidFinishLoad method to hide it once it's loaded
- (void)webViewDidFinishLoad:(UIWebView *)localwebView {
myView.hidden = YES;
}
这篇关于在 UIWebView 上显示背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!