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

それは、以前にそのイメージを読み込んでいたことが原因だったので、OS が結果をキャッシュしたと思います。そのため、既にダウンロードされているため、100% の進行状況しか返されませんでした。

于 2013-12-30T16:14:24.597 に答える