作者:朱克锋
邮箱:zhukefeng@iboxpay.com
转载请注明出处:http://blog.youkuaiyun.com/linux_zkf
@interface TestViewController : UIViewController <UIAlertViewDelegate>
{
UIAlertView *baseAlert;
}
@end
@implementation TestViewController
- (void) dismiss
{
[baseAlert dismissWithClickedButtonIndex:0 animated:NO];
}
- (void) action: (UIBarButtonItem *) item
{
baseAlert = [[[UIAlertView alloc] initWithTitle:@"请稍后。。。" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease];
[baseAlert show];
//创建并添加一个活动指示器
UIActivityIndicatorView *aiv = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
aiv.center = CGPointMake(baseAlert.bounds.size.width / 2.0f, baseAlert.bounds.size.height - 40.0f);
[aiv startAnimating];
[baseAlert addSubview:aiv];
[aiv release];
// 3s后自动消失
[self performSelector:@selector(dismiss) withObject:nil afterDelay:3.0f];
}