:おそらくこのようなコードで
。あなたはそのようNSURLConnectionコールバックでこれらのプロパティを設定する必要があります。
- (void)connection:(NSURLConnection *)__unused connection
didSendBodyData:(NSInteger)bytesWritten
totalBytesWritten:(NSInteger)totalBytesWritten
totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
{
[super connection: connection didSendBodyData:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite];
self.totalBytesSent = totalBytesWritten;
self.totalBytesExpectedToSend = totalBytesExpectedToSend;
}
あなたuploadprogressのブロックは次のようになります。
……(NSInteger bytesWritten, NSInteger totalBytesWritten, NSInteger totalBytesExpectedToWrite) {
NSInteger queueTotalExpected = 0;
NSInteger queueTotalSent = 0;
for (AFURLConnectionOperation *operation in self.operationQueue) {
queueTotalExpected += operation.totalBytesExpectedToSend;
queueTotalSent += operation.totalBytesSent;
}
self.totalProgress = (double)queueTotalSent/(double)queueTotalExpected;
}];
ですデザインパターン。おそらく、 –
。これは動的サイズのコンテンツの仕事に適したツールです。コンテンツのサイズを最初に知る必要なしに、進捗状況を正確に表示します。大きなファイル(ビデオや写真など)のサイズを見つけることは、費用のかかる操作になります。 – clreina