【发布时间】:2013-12-19 20:20:38
【问题描述】:
我正在下载一张图片,并希望展示某种形式的下载进度:
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:post.url]];
AFHTTPRequestOperation *imageOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
imageOperation.responseSerializer = [AFImageResponseSerializer serializer];
[imageOperation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
NSLog(@"bytesRead: %d, totalBytesRead: %lld, totalBytesExpected: %lld", bytesRead, totalBytesRead, totalBytesExpectedToRead);
}];
我还有一个完成块,然后是[imageOperation start];。
但是,如果我选择要下载的图像,我所记录的只是:
bytesRead:72081,totalBytesRead:72081,totalBytesExpected:72081
为什么最后只给我信息?
【问题讨论】:
-
HTTP 服务器是否返回 Content-Length 标头?试试
curl -I <URL>
标签: ios objective-c afnetworking nsurlrequest afhttprequestoperation