1

我正在下载一张图片,并希望展示某种形式的下载进度:

    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

为什么最后只给我信息?

4

1 回答 1

1

最终是由于我之前已经加载了该图像,所以我假设操作系统缓存了结果。所以它只返回了 100% 的进度,因为它已经下载了。

于 2013-12-30T16:14:24.597 回答