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:
UIActivityIndicato开发者_开发百科rView *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?
please move
[activityIndicatorTemp release];
after addSubview:
[[self tableView] addSubview:activityIndicator];
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.
精彩评论