Thursday, April 21, 2011

How to display UIActivityIndicator in the center of the NavigationBar?

Hey all,

i want to display my Activity Indicator in the center of the Navigation Bar. At the Moment its on the rightBarButtonItem.

How can this be done?

Thanks for help!

From stackoverflow
  • Easiest way is to add a UIActivityIndicatorView on top of your navigation bar, and show/hide it as needed.

  • here's another way to insert a custom UIView directly into the UINavigationBar with UINavigationItem's property:

    @property(nonatomic, retain) UIView *titleView
    

    and where navController is the UINavigationController that your view (managed by UINavigationbar) is in...

    UIActivityIndicatorView *aView = [[UIActivityIndicatorView alloc] init];
    
    navController.navigationItem.titleView = aView;
    [aView release];
    

    should do the trick

0 comments:

Post a Comment