0

I am downloading PDF file in my application and I want to show download progress bar when PDF downloading get started,I searched for this but didn't get any useful tutorial or answer,Can any one tell me any link or tutorial? Please help me, Thanks in advance.

user3007459
  • 113
  • 1
  • 13

3 Answers3

0

You can use an NSURLConnection (here's an example) to get the remote file. The NSURLConnectionDataDelegate gets called with progress as data is received.

In order to estimate progress, you need to know (or have an estimate of) the number of bytes in the downloading file.

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    // allocate mutable responseData when connection didReceiveResponse
    [self.responseData appendData:data];

    float progress = self.responseData.length / self.expectedLength;
    // this is the percentage progress
}
Community
  • 1
  • 1
danh
  • 62,181
  • 10
  • 95
  • 136
0

You can follow this link to display PDF download progress even if with multiple PDF files are downloading in queue. I mean you can display download progress status not only for single PDF file but also for multiple downloading PDF files in the application: http://allseeing-i.com/ASIHTTPRequest/How-to-use

Gaurav
  • 299
  • 4
  • 15
0

You can use AFHTTPRequestOperation to get the remote file, for the progress you can try this code :

This will show you progress in progress view.

 [httpClient enqueueBatchOfHTTPRequestOperations:tempOperations
                                  progressBlock:^(NSUInteger numberOfCompletedOperations, NSUInteger totalNumberOfOperations) {

                                    float  progressValue=(float)numberOfCompletedOperations/(float)totalNumberOfOperations;
                                      NSLog(@"%f", progressValue);
                                      NSLog(@"%d / %d", numberOfCompletedOperations, totalNumberOfOperations);

                                      [progressValueLabel setText:[NSString stringWithFormat:@"%.0f%%", (progressValue * 100)]];
                                      [progressView setProgress:progressValue];
                                  }
                                    completionBlock:nil];
Sangram Shivankar
  • 3,535
  • 3
  • 26
  • 38
Anand
  • 22
  • 2