tags:

views:

289

answers:

2

I want to display q UIACtivitiyIndicatorView when i click on a tab bar item, while data is being loaded on that view controller. I have added this indicator on viewWillAppear method of the view controller but it shows indicator wen views appears on the screen. How to make indicator visible when screen working on loading data

+3  A: 

In your viewWillAppear, do:

self.activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
self.activityIndicator.hidesWhenStopped = TRUE;

When you begin loading data, call

[self.activityIndicator startAnimating];

When you are finished, call

[self.activityIndicator stopAnimating];
groundhog
A: 

You can also explicitly call setHidden on the activity indicator:

[activityIndicator setHidden:YES];
Matt Long