Skip to content

Instantly share code, notes, and snippets.

@xandrucea
Created July 15, 2013 12:51
Show Gist options
  • Save xandrucea/5999698 to your computer and use it in GitHub Desktop.
Save xandrucea/5999698 to your computer and use it in GitHub Desktop.
Alertview with Activity inidicator
UIActivityIndicatorView *activityView;
UIAlertView *waitAlertView;
// delegate method of alert view
- (void)willPresentAlertView:(UIAlertView *) currAlertView {
if ( waitAlertView == currAlertView) {
activityView.center = CGPointMake( waitAlertView.bounds.size.width / 2, waitAlertView.bounds.size.height / 2 );
}
}
// create alert view with indicator
- (void)showAction{
// create alert view with activity indicatord
waitAlertView = [[UIAlertView alloc] initWithTitle:nil
message:nil
delegate:self
cancelButtonTitle:nil
otherButtonTitles:nil];
activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
float frameX = self.view.frame.size.width / 2.0f;
float frameY = self.view.frame.size.height / 2.0f;
CGPoint viewCenter = CGPointMake(frameX, frameY);
activityView.center = viewCenter;
[waitAlertView addSubview:activityView];
}
// call alertview with indicator view animated
[self showAction];
[activityView startAnimating];
[waitAlertView show];
// dismiss alertview with indicator view
[waitAlertView dismissWithClickedButtonIndex:0 animated:YES];
waitAlertView = nil;
//call your view
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment