Hab
Hab

Reputation:

UIActivityIndicatorView problem

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

Upvotes: 0

Views: 1038

Answers (2)

Matt Long
Matt Long

Reputation: 24466

You can also explicitly call setHidden on the activity indicator:

[activityIndicator setHidden:YES];

Upvotes: 0

groundhog
groundhog

Reputation: 4780

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];

Upvotes: 3

Related Questions