2010-01-21 33 views

回答

2

如果你在网络上谈论加载数据,ASIHTTPRequest提供了一种将参考传递给UIProgressView的方法,它将以更准确的进度更新下载和上传。我强烈推荐它。

0

您的意思是进度条或活动指标吗?对于正在发生的活动,您可以使用UIActivityIndicatorView

流程看起来有点像这样。

UIActivityIndivatorView *activity = [[UIActivityIndivatorView alloc] init]; 
//attach activity to a view or a bar 

//begin activity 

[activity startAnimating]; 

//here will be the functionality for your data gathering progress 

//once your progress or activity is done 

[activity stopAnimating]; 

希望这会有所帮助。

1

在我为公司编写的应用程序中执行非常长的同步(通过访问Web服务)的应用程序中,显示UIActivityIndi​​catorView。

在同一视图中,我还包含一个标签,显示“获取Y的X ...”标签通过NSTimer更新。呼叫的样子:

timer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(updateLabel:) userInfo:nil repeats:YES]; 

此外,为了实际更新UI,我不得不剥离的代码从Web服务的数据提取到自己的线程。

+0

我还想提及的是,UI更新井活动确实需要在后台线程中... – 2010-01-21 19:52:28

2

如果你只想在状态的小型网络微调您

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES; 

激活它......和停用

[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;