Wednesday, April 6, 2011

Simple Custom loading alert view

UIActivityIndicatorView* spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[spinner setCenter:CGPointMake(140, 100)];

NSString* messageTitleToUser = @"Favorites list";
 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:messageTitleToUser message:@"loading..." delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil];

  [alertView addSubview:spinner];
  [spinner startAnimating];
  [alertView show];

....
...
...

//if you programmatically want to close the alert view
 [alertView dismissWithClickedButtonIndex:0 animated:YES];
// stop spinner
[spinner stopAnimating];


References:
http://stackoverflow.com/questions/593234/how-to-use-activity-indicator-view-on-iphone


No comments: