在UIWebView上显示背景图像 [英] Displaying a background image on UIWebView

查看:131
本文介绍了在UIWebView上显示背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图构建一个原生应用程序,其目的和目的都是HTML / CSS和Javascript。这一切工作正常,但是当UIWebView加载时有一个延迟,而DOM填充,图像检索等。

是否有在UIWebView上显示背景图像,或背后的东西?理想情况下,这将与启动画面相同,因此它不会影响从斜杠切换到应用程序的体验。



谢谢

Robbie

解决方案

我不相信您希望将UIWebView设置为透明并显示图像然后你应该有某种观点(也许有你想象中的一张照片,也许有一个UIIndicator和一个半透明的视图,可以暗淡页面),直到UIWebView加载它的内容。



为此,首先你的类应该订阅UIWebViewDelegate协议:

  @interface myWebView:UIViewController< UIWebViewDelegate> {
//变量等
}

然后,您可以显示一个视图在加载时:

   - (void)viewDidLoad {
myView.hidden = NO;





$ b

最后,您可以覆盖webViewDidFinishLoad方法以在加载后隐藏它

   - (void)webViewDidFinishLoad:(UIWebView *)localwebView {
myView.hidden = YES;
}


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.

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.

Thanks

Robbie

解决方案

I don't believe you want to be setting the UIWebView as transparent and showing an image behind it.

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.

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;
}

And finally, you can override the webViewDidFinishLoad method to hide it once it's loaded

- (void)webViewDidFinishLoad:(UIWebView *)localwebView {
    myView.hidden = YES;
}

这篇关于在UIWebView上显示背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆