Activity indicator in UITableView in iphone app
In my iphone app I have a table view. In that onclick of each row it will download some data. During that download process I need to anima开发者_Go百科te an activity indicator. How to add an activity indicator in table view?
First, you do not need to add activity indicator in table view. You just add it in that view and then set its hidden property. When the user clicks on a row, set its hidden property to NO.
One more thing, move your table to send to back from layout->send to back and the indicator to send to front layout->sent to front.
Just add an UIActivityIndicatorView to your view say activity
Assign it the frame and style you want.
Then all you need to do is that put the below code above your download code.
[NSThread detachNewThreadSelector:@selector(myMethod:) toTarget:self withObject:nil];
and you need to declare myMethod as
-(void)myMethod:(id)data
{
[activity startAnimating];
[activity setHidden:NO];
}
Whenever your download finishes just put
[activity stopAnimating];
[activity setHidden:YES];
Hope this helps you.
精彩评论