Skip to content

Instantly share code, notes, and snippets.

@marshluca
Created August 9, 2010 04:59
Show Gist options
  • Save marshluca/514960 to your computer and use it in GitHub Desktop.
Save marshluca/514960 to your computer and use it in GitHub Desktop.
Add UIActivityIndicatorView or UIProgressView to UIAlertView
// display the alert view
- (void)createProgressionAlertWithTitle:(NSString *)title message:(NSString *)message andIsActivity:(BOOL)isActivity
{
UIAlertView *progressAlert = [[UIAlertView alloc] initWithTitle:title message:message delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
// Create the progress bar and add it to the alert
if (isActivity)
{
UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activityView.frame = CGRectMake(139.0f-18.0f, 60.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];
}
// dismiss the alert view
- (void)dismissProgressAlert {
[progressAlert dismissWithClickedButtonIndex:0 animated:YES];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment