Thanks! My indicator is working now.
I am sharing a code example for fellow noobs, to put this in context.
- (void)viewDidLoad
// custom button images
UIImage *customImage = [UIImage imageNamed:@"menu24"];
UIImage *customImage2 = [UIImage imageNamed:@"search24"];
UIImage *customImage3 = [UIImage imageNamed:@"back24"];
// These are linked in my story board to Navigation Item
[self customiseBarBtnItem:[self menu_button]
customImage:customImage selector:@selector(menuPressed:)];
[self customiseBarBtnItem:[self search_button]
customImage:customImage2 selector:@selector(searchPressed:)];
[self customiseBarBtnItem:[self backButton]
customImage:customImage3 selector:@selector(backPressed:)];
//initialize the activity indicator - as @antf comment suggests for ios7
UIActivityIndicatorView *actInd=[[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
//store it as a property on the view controller
self.activityIndicator = actInd;
// this sets up activity indicator
UIBarButtonItem *progress_indicator = [[UIBarButtonItem alloc]
initWithCustomView:[self activityIndicator]];
// link custom buttons AND activity indicator in desired order to navigation bar
self.navigationItem.rightBarButtonItems =
[NSArray arrayWithObjects:
self.menu_button,
self.search_button,
progress_indicator,
nil];
// For completeness - this is how I programmatically show/hide my back button
if ( bShowBack == YES )
self.navItemBar.leftBarButtonItem = self.backButton;
else
self.navItemBar.leftBarButtonItem = Nil;
// I use my activity indicator with a UIWebView so trigger it as follows
- (void)webViewDidStartLoad:(UIWebView *)webView
{
[[self activityIndicator] startAnimating];
}
- (void)didFailLoadWithError:(UIWebView *)webView
didFailLoadWithError:(NSError *)error
{
[[self activityIndicator] stopAnimating];
}
- (void)webViewDidFinishLoad:(UIWebView *) webView
{
[[self activityIndicator] stopAnimating];
}
activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
or the indicator will not appear. – Diestock