Merci! Mon indicateur fonctionne maintenant. Je partage un exemple de code pour les autres noobs, pour mettre ceci en contexte.
- (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];
// Pour être complet - voici comment je montre programme/cacher mon bouton retour
if (bShowBack == YES)
self.navItemBar.leftBarButtonItem = self.backButton;
else
self.navItemBar.leftBarButtonItem = Nil;
// J'utilise mon activité indicateur avec un UIWebView donc le déclencher comme suit
- (void)webViewDidStartLoad:(UIWebView *)webView
{
[[self activityIndicator] startAnimating];
}
- (void)didFailLoadWithError:(UIWebView *)webView
didFailLoadWithError:(NSError *)error
{
[[self activityIndicator] stopAnimating];
}
- (void)webViewDidFinishLoad:(UIWebView *) webView
{
[[self activityIndicator] stopAnimating];
}
J'ai remarqué que sur iOS 7, vous devez utiliser 'activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleGray];' ou l'indicateur n'apparaîtra pas. – antf