-2
我正在制作一款应用程序,可通过按钮单击下载PDF文件并通过应用程序的沙箱将其保存到本地。目标C:下载时的进度条
现在,我想在下载过程中放置一个进度条,我将如何能够做到这一点?
我已成功地做下载和使用此代码的文件的查看...
存储数据:
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];
这拖文件夹形式顺便说一句 - 你不会要能够做多少,你正在使用的同步方法。 – Abizern 2013-05-08 05:45:49