您好,欢迎访问一九零五行业门户网

UIWebView解决加载页面时背景一片空白问题_html/css_WEB-ITnose

uiwebview加载过程中,在页面没有加载完毕前,会显示一片空白。为解决这个问题,方法如下:
方法1、让uiwebview背景透明。
webview.backgroundcolor = [uicolor clearcolor];webview.opaque = no;[webview setbackgroundcolor:[uicolor colorwithpatternimage:[uiimage imagenamed:@webbg.png]]];
方法2:
先将webview的frame设为0, 在页面加载完成后再将frame设为原来大小.
方法3:
在viewdidload中,在webview上面覆盖一个背景视图。
self.webview=[[[uiwebview alloc]initwithframe:self.view.bounds]autorelease]; [self.webview loadrequest:request]; [self.view addsubview:self.webview]; uiimageview *imageview = [[uiimageview alloc]initwithimage:[uiimage imagenamed:@gatewaybg.png]]; imageview.frame = cgrectmake(0, 0, [uiscreen mainscreen].bounds.size.width, [uiscreen mainscreen].bounds.size.height); [self.view addsubview:imageview];
然后在webview加载完成后把视图放到最上层或移除背景视图。
- (void)webviewdidfinishload:(uiwebview *)webview{ // webview放到最上层 [self.view bringsubviewtofront:self.webview]; // 或者可以把背景图移除 [self.webview removefromsuperview];}
其它类似信息

推荐信息