Help me! I want download a file. And how display progress bar?

I read a lot of articles and I do not work, do not work, you can explain to me how to do it?

有帮助吗?

解决方案

You can get expected total file size in following callback method of NSURLconnection,

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
   expectedTotalSize = response.expectedContentLength;
}

then in the following callback method you can calculate how much data has been recieved,

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
   recievedData += data.length;
}

And you can use UIProgressView to show current downloading status on the screen.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top