문제

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