当前位置: 动力学知识库 > 问答 > 编程问答 >

objective c - 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 animate an activity indicator. How to add an activity indicator in table view?

网友答案:

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.

网友答案:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: