【问题标题】:Show progress for downloading image using AFNetworkig显示使用 AFNetworking 下载图像的进度
【发布时间】:2015-03-03 10:21:29
【问题描述】:

我想在下载大图时显示进度。我是 设置图片路径如下。

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

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

【问题讨论】:

标签: ios afnetworking progress download


【解决方案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);   
}];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-30
    相关资源
    最近更新 更多