-2

我正在制作一个应用程序,通过单击按钮下载 PDF 文件并通过应用程序的沙箱将其保存在本地。

现在,我想在下载过程中放置​​一个进度条,我该怎么做呢?

我已经设法使用此代码下载和查看文件...

存储数据:

    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];

文件查看:

    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];
4

1 回答 1

0

试试这个演示下载进度条

NPR图像视图

当您下载两个文件夹文件时可能会丢失并给您一个错误。在此处下载此拖车文件夹表格

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

于 2013-05-08T05:18:59.673 回答