UIWebView加载Loading...两种方法
第一种方法:使用UIView and UIActivityIndicatorView
//创建UIWebView
WebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 44, 320, 400)];
[WebView setUserInteractionEnabled:NO];
[WebView setBackgroundColor:[UIColor clearColor]];
[WebView setDelegate:self];
[WebView setOpaque:NO];//使网页透明
NSString *path = @"http://www.baidu.com";
NSURL *url = [NSURL URLWithString:path];
[WebView loadRequest:[NSURLRequest requestWithURL:url]];
//创建UIActivityIndicatorView背底半透明View
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];
activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 32.0f, 32.0f)];
[activityIndicator setCenter:view.center];
[activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];
[view addSubview:activityIndicator];
[self.view addSubview:WebView];
[view release];
[WebView release];
//开始加载数据
- (void)webViewDidStartLoad:(UIWebView *)webView {
[activityIndicator startAnimating];
}
//数据加载完
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[activityIndicator stopAnimating];
UIView *view = (UIView *)[self.view viewWithTag:103];
[view removeFromSuperview];
}
第二种方法:使用UIAlertView and UIActivityIndicatorView
//加载网页动画
- (void)webViewDidStartLoad:(UIWebView *)webView{
if (myAlert==nil){
myAlert = [[UIAlertView alloc] initWithTitle:nil
message: @"读取中..."
delegate: self
cancelButtonTitle: nil
otherButtonTitles: nil];
UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activityView.frame = CGRectMake(120.f, 48.0f, 38.0f, 38.0f);
[myAlert addSubview:activityView];
[activityView startAnimating];
[myAlert show];
}
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
[myAlert dismissWithClickedButtonIndex:0 animated:YES];
}
|
相关推荐
TabLayout我相信大家都有使用过,但是官方并没有对Indicator可以设置为图片的支持,只能是简单的水平线,也就是滑动杆那个玩意,那么如何做到可以用图片来做**指示器**呢?
CircularProgressIndicator - 可定制的循环进度指示器
Dinapoli indicator target. For trading forex. Best indicator
给ViewPager添加indicator
Flutter自定义TabBar的Indicator 实现秒杀Tab效果
Fragment+viewpagerIndicator实现APP主界面.zip
indicator binary options clubinarias
Android Tablayout 的Indicator 长度的修改(这里只适用于:1.指示器长度和文字长度相等,2.指示器长度填满整个TabItem)
pinbar indicator for forex trading and scalping
基于 Hans_Indicator_Cloud_System 指标信号的交易系统,可设置固定的持仓时间
Indicator-Sysmonitor脚本,结合Indicator-Sysmonitor使用可以在顶部工具栏显示CPU,内存占用率,CPU温度,网络上行、下行速度。
Tick based RSI like custom indicator function written by C++.
Tab底部页签点击切换Fragment,底部页签带角标显示效果
Grail-Indicator is one of Binary Option indicator System
this indicator to optimized analyse forex trading for all pair and any time frame
包含五种分类模型常用的性能测试指标,已经通过测试,可用!!!
Android viewpage 水平滑动分页 加indicator, viewpage 水平滑动分页 加indicator
EMA_Trend_Indicator.
Indicator for mt4 no repaint
Binary options boss indicator