我无法让我的活动指示器工作。
这就是我所拥有的-
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:YES];
//Create an instance of activity indicator view
UIActivityIndicatorView * activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
//set the initial property
[activityIndicator stopAnimating];
[activityIndicator hidesWhenStopped];
//Create an instance of Bar button item with custome view which is of activity indicator
UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithCustomView:activityIndicator];
//Set the bar button the navigation bar
[self navigationItem].rightBarButtonItem = barButton;
//Memory clean up
[activityIndicator release];
[barButton release];
}
应该让它开始然后结束的代码部分 -
...
else if ([theSelection isEqualToString: @"Update statistics"])
{
[self startTheAnimation];
[updateStatistics updateThe2010Statistics];
[self stopTheAnimation];
}
...
-(void)startTheAnimation {
[(UIActivityIndicatorView *)[self navigationItem].rightBarButtonItem.customView startAnimating];
}
-(void)stopTheAnimation {
[(UIActivityIndicatorView *)[self navigationItem].rightBarButtonItem.customView stopAnimating];
}