Posted By

suibhne on 12/02/09


Tagged

Objective-c iphone


Versions (?)

Add Activity Indicator to Navigation Controller Bar


 / Published in: Objective C
 

This adds a spinning activity indicator to the top navigation bar of a navigation controller.

  1. // stop activity indicator
  2. UINavigationController *tempNavigationController = [self.navigationController.viewControllers objectAtIndex:2];
  3. CGRect frame = CGRectMake(0.0, 0.0, 25.0, 25.0);
  4. UIActivityIndicatorView *loading = [[UIActivityIndicatorView alloc] initWithFrame:frame];
  5. [loading sizeToFit];
  6. loading.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin);
  7. UIBarButtonItem *statusInd = [[UIBarButtonItem alloc] initWithCustomView:loading];
  8. statusInd.style = UIBarButtonItemStylePlain;
  9. [tempNavigationController.navigationItem setRightBarButtonItem: statusInd animated:YES];

Report this snippet  

You need to login to post a comment.