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

WBOY
풀어 주다: 2016-06-24 11:46:22
원래의
1177명이 탐색했습니다.

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];}
로그인 후 복사


원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!