博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Add an UIProgressView or UIActivityIndicatorView to your UIAlertView

Posted on 2010-03-09 21:28  BradyChen  阅读(1649)  评论(0编辑  收藏  举报

- (void) createProgressionAlertWithMessage:(NSString *)message withActivity:(BOOL)activity
{
UIAlertView *progressAlert = [[UIAlertView alloc] initWithTitle: message
    message: @"Please wait..."
  delegate: self
  cancelButtonTitle: nil
  otherButtonTitles: nil];

// Create the progress bar and add it to the alert
if (activity) {
UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activityView.frame = CGRectMake(139.0f-18.0f, 80.0f, 37.0f, 37.0f);
[progressAlert addSubview:activityView];
[activityView startAnimating];
} else {
UIProgressView *progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(30.0f, 80.0f, 225.0f, 90.0f)];
[progressAlert addSubview:progressView];
[progressView setProgressViewStyle: UIProgressViewStyleBar];
}
[progressAlert show];
[progressAlert release];
}






自动消失的UIAlertView