我正在尝试更新标签以显示要使用AFNetworking框架下载的文件的进度。问题是,当我将百分比设置为setProgressiveDownloadProgressBlock 中的标签时,标签仅在下载开始和下载完成时更新。
__weak MTCViewController *weakSelf= self;
[_operation setProgressiveDownloadProgressBlock:^(AFDownloadRequestOperation *operation, NSInteger bytesRead, long long totalBytesRead, long long totalBytesExpected, long long totalBytesReadForFile, long long totalBytesExpectedToReadForFile) {
float percent = (float)(totalBytesRead / totalBytesExpectedToReadForFile)*100;;
// [weakSelf updateProgress:percent];
[weakSelf updateText:[NSString stringWithFormat:@"Progress = %f",percent]];
}];
[_operation start];
另外,当我删除标签更新代码时,块似乎正在正确更新