下载文件iOS时的进度条 [英] Progress bar while downloading files iOS
本文介绍了下载文件iOS时的进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用以下内容从互联网上下载文件:
I am using the following to download the files from the internet:
NSData * myXMLData1 = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@Link]];
现在,我想在下载过程中放置一个进度条。我查了各种各样的帖子,但我无法确切地知道如何做到这一点。
Now, I would like to put a progress bar while the download is going on. I checked various posts but i am not able to find out how to do it exactly.
请帮助我!!
推荐答案
添加
expectedBytes = [response expectedContentLength];
到
-(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
并添加
float progress = ((_bytesReceived/(float)_expectedBytes)*100)/100;
到
-(void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
然后setPr ogress:在你的UIProgressView上
then setProgress: on your UIProgressView
来自:
http://www.developers-life.com/progress-bar-download-file-on-iphone.html
这篇关于下载文件iOS时的进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文