I am trying to manage the activity indicator from my App Delegate, that way any of my views can put the indicator up. So, I am adding it as a subview to 'window' and start/stop as follows:
- (void)didStartActivity
{
if( activityIndicator == nil ) {
activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
activityIndicator.hidesWhenStopped = YES;
activityIndicator.center = window.center;
activityIndicator.transform = CGAffineTransformScale(CGAffineTransformIdentity, 6.0, 6.0);
}
NSLog(@"%s: starting the activityIndicator", __FUNCTION__);
[window addSubview:activityIndicator];
[activityIndicator startAnimating];
}
I see the log messages, so I know the code is being invoked. The indicator is at the center and 6x the default size. However, the stopAnimating isn't stopping. The only thing I can conclude is that it needs to run in the present view controller.
- (void)didStopActivity
{
NSLog(@"%s: stopping the activityIndicator", __FUNCTION__);
[activityIndicator stopAnimating];
[activityIndicator removeFromSuperview];
}