iphone 等待进度条

方法3:

UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];//指定进度轮的大小
[activity setCenter:CGPointMake(160, 140)];//指定进度轮中心点
[activity setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhiteLarge];//设置进度轮显示类型
[self.view addSubview:activity];
[super viewDidLoad];
[activity startAnimating];
// [activity stopAnimating];


方法1:

//success 滚动条
-(void)waitequan{
//创建UIWebView
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 {
NSLog(@"begin");
[activityIndicator startAnimating];
}

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


方法2:


- (void)showProgressAlert{
UIAlertView* alertView = [[[UIAlertView alloc] initWithTitle:@"title"
message:@"hello"
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:nil]
autorelease];

progressView_ = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
progressView_.frame = CGRectMake(30, 80, 225, 30);
[alertView addSubview:progressView_];

[alertView show];
}
- (void)updateProgress:(NSNumber*)progress {
progressView_.progress = [progress floatValue];
}
- (void)dismissProgressAlert {
if (progressView_ == nil) {
return;
}

if ([progressView_.superview isKindOfClass:[UIAlertView class]]) {
UIAlertView* alertView = (UIAlertView*)progressView_.superview;
[alertView dismissWithClickedButtonIndex:0 animated:NO];
}

[progressView_ release];
progressView_ = nil;
}

- (void)processData:(int)total {
for (int i = 0; i < total; ++i) {
// Update UI to show progess.
float progress = (float)i / total;
NSNumber* progressNumber = [NSNumber numberWithFloat:progress];
[self performSelectorOnMainThread:@selector(updateProgress:)
withObject:progressNumber
waitUntilDone:NO];

// Process.
// do it.
}

// Finished.
[self performSelectorOnMainThread:@selector(dismissProgressAlert)
withObject:nil
waitUntilDone:YES];
// Other finalizations.
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值