Ser Pounce
Ser Pounce

Reputation: 14571

UIActivityIndicatorView not working when added to UITableView

I'm trying to add a UIActivityIndicatorView to the center of my UITableView while it waits for the UITableViews data to load. I am doing this as follows:

UIActivityIndicatorView *activityIndicatorTemp = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleWhiteLarge];
[activityIndicatorTemp setCenter:[[self tableView] center]];
[self setActivityIndicator: activityIndicatorTemp]; 
[activityIndicatorTemp release];
[[self tableView] addSubview:activityIndicator];
[activityIndicator startAnimating]; 

However the activity indicator is not showing up at all when I launch the code. I'd like to do it programmatically, any suggestions on how to fix this or why it isn't working?

Upvotes: 0

Views: 2556

Answers (2)

Ser Pounce
Ser Pounce

Reputation: 14571

The problem here is when I was setting the location of the activityindicator. I did this before the tableview had been initialized.

[activityIndicatorTemp setCenter:[[self tableView] center]];

I removed the above and it worked.

Upvotes: 0

Saurabh Passolia
Saurabh Passolia

Reputation: 8109

please move

[activityIndicatorTemp release];

after addSubview:

[[self tableView] addSubview:activityIndicator];

Upvotes: 1

Related Questions