UIWebView加载Loading效果

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
[view setTag:103];
[view setBackgroundColor:[UIColor blackColor]];
[view setAlpha:0.8];
[self.view addSubview:view];
	
UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 32.0f, 32.0f)];
[activityIndicator setCenter:view.center];
[activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];
[view addSubview:activityIndicator];
	
[view release];

 

UIWebView需要指定自己为Delegate

 

//开始加载数据
- (void)webViewDidStartLoad:(UIWebView *)webView {    
	[activityIndicator startAnimating];         
}

//数据加载完
- (void)webViewDidFinishLoad:(UIWebView *)webView {
	[activityIndicator stopAnimating];    
	UIView *view = (UIView *)[self.view viewWithTag:103];
	[view removeFromSuperview];
}

 

你可能感兴趣的:(ios,UIWebView,iPhone)