在做一些耗时操作时,往往需要像Android一样的一个等待对话框,如下图所示
主要代码:
-(IBAction)onClickButton:(id)sender {
txtField.text = @"Hello World.";
UIAlertView* alert = [[UIAlertView alloc] initWithTitle"执行中"
message:nil
delegate:self //
cancelButtonTitle:nil
otherButtonTitles:nil, nil];
NSLog(@"test .......");
[alert show];
UIActivityIndicatorView* uiaiv = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
uiaiv.center = CGPointMake(alert.bounds.size.width / 2.0f, alert.bounds.size.height/2.0f);
[uiaiv startAnimating];
[alert addSubview:uiaiv];
[uiaiv release];
[alert release];
}