-2

I am making an app that downloads PDF File on button click and save it on locally through the app's sandbox.

Now, I want to put a progress bar during the download, how will I able to do that?

I have managed to do the downloading and viewing of the the file with this code...

Storing Data:

    NSData *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://mywebsite.com/products/download/file.pdf"]];

    NSString *resourceDocPath = [[NSString alloc] initWithString:[[[[NSBundle mainBundle]  resourcePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"Documents"]];

    filePath = [resourceDocPath stringByAppendingPathComponent:@"myPDF.pdf"];

    [pdfData writeToFile:filePath atomically:YES];

File View:

    UIWebView *pdfFileView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
    pdfFileView.delegate = self;
    pdfFileView.backgroundColor = [UIColor clearColor];
    pdfFileView.opaque = NO;
    pdfFileView.userInteractionEnabled = YES;
    [self.view addSubview:pdfFileView];

    NSURL *url = [NSURL fileURLWithPath:filePath];

    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

    [pdfFileView loadRequest:requestObj];
Chano Tarongoy
  • 155
  • 1
  • 2
  • 8
  • As an aside - you aren't going to be able to do much with the synchronous method you are using. – Abizern May 08 '13 at 05:45

1 Answers1

0

try this demo for downloading with progressbar

NPRImageview

When you download two folder file are may be missing and gives you an error. download this tow folder form here

https://github.com/nicnocquee/NPRImageView/

Wukerplank
  • 4,156
  • 2
  • 28
  • 45
SAMIR RATHOD
  • 3,512
  • 1
  • 20
  • 45