如何添加用于下载大图片或任何文件的进度条?这是我的代码:
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *docsPath = [paths objectAtIndex:0];
NSString *downloadPath = [[[NSString alloc]initWithFormat:@"http://www.zzz.com/%@.jpg",chartFileName]autorelease];
NSString *savePath = [[[NSString alloc]initWithFormat:@"%@/%@.jpg",docsPath, chartFileName]autorelease];
NSURL *url = [[NSURL alloc]initWithString:downloadPath];
NSData *downloadedChartData = [NSData dataWithContentsOfURL:url];
[url release];
[downloadedChartData writeToFile:savePath atomically:YES];
答案 0 :(得分:1)
您可以在NSURLConnection调用中覆盖connection:didReceiveData :.请点击此处了解更多信息:
答案 1 :(得分:0)
在后台运行一个检查图像下载大小的选择器,并将其与所需大小进行比较。然后将进度条的%设置为已下载/必需。