开发者

UIActivityIndicatorView not working when added to UITableView

开发者 https://www.devze.com 2023-04-09 07:38 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消