2012-05-07 54 views
6

我使用下面的從互聯網上下載的文件:現在進度條文件,同時下載的iOS

NSData *myXMLData1 = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"Link]];

,我想提出一個進度條,而下載是怎麼回事。我查了各種帖子,但我無法找到如何完全做到這一點。

請幫助我!

+0

經過http://stackoverflow.com/questions/2267950/how-to-make-an-progress- bar-for-an-nsurlconnection-when-downloads-a-file – NAZIK

+0

@Azik 但是,我在使用NSURLConnection時也遇到了一些問題。你給的鏈接是在我使用NSURLConnection下載我的文件之後? – user1228074

回答

8

添加

expectedBytes = [response expectedContentLength]; 

-(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response 

,並添加

float progress = ((_bytesReceived/(float)_expectedBytes)*100)/100; 

-(void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data 

然後setProgress:您UIProgressView

來源: http://www.developers-life.com/progress-bar-download-file-on-iphone.html