方法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.
}
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.
}