2015-03-03 100 views
0

我想在下载大图像时显示进度。我是 设置图像路径如下。使用AFNetworkig显示下载图像的进度

UIImage *backgroundImage =[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:backgoundImagePath]]]; 

如何使用AFNetworking框架显示图像的下载进度。

+0

尝试这样做:http://stackoverflow.com/questions/19145093/how-to-get-download-progress-in-afnetworking-2-0? – sasquatch 2015-03-03 10:26:05

回答

1

试试这个,

[manager setDownloadTaskDidWriteDataBlock:^(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite) { 
float percentageDone = ((float)totalBytesWritten/(float)totalBytesExpectedToWrite)*100; 
     NSLog(@"Downloading..%.f",percentageDone); 
}];