나는 파일을 1 %에서 100 %까지 다운로드하는 과정을 보여주는 코드를 사용합니다.레이블에 퍼센트 표시
if(downloadTask == _downloadTask26){
_progress26 = [[NSNumber numberWithInteger:totalBytesWritten] floatValue];
_total26 = [[NSNumber numberWithInteger:totalBytesExpectedToWrite] floatValue];
}
if(downloadTask == _downloadTask27){
_progress27 = [[NSNumber numberWithInteger:totalBytesWritten] floatValue];
_total27 = [[NSNumber numberWithInteger:totalBytesExpectedToWrite] floatValue];
}
float progress = _progress26 + _progress27;
float total = _total26 + _total27;
NSString *percentage = [NSString stringWithFormat:@"%.f%%", ((progress/total) * 100)];
(NSLog (percentage, @"%.f%%"));
if (!_label3) {
_label3 = [[UILabel alloc] initWithFrame:CGRectMake(200.43, 158.84, 42, 19)];
_label3.numberOfLines = 1;
_label3.baselineAdjustment = UIBaselineAdjustmentAlignBaselines;
_label3.adjustsFontSizeToFitWidth = YES;
_label3.minimumScaleFactor = 10.0f/12.0f;
_label3.clipsToBounds = YES;
_label3.backgroundColor = [UIColor clearColor];
_label3.textColor = [UIColor whiteColor];
_label3.textAlignment = NSTextAlignmentCenter;
[_scroller addSubview:_label3];
}
}
_label3.text = percentage;
if ([_label3.text isEqual: @"100%"]) {
}
그러나 파일 다운로드시 퍼센트가 오름차순으로 표시되지 않습니다. 비율은 아래 비디오와 같이 다른 순서로 표시됩니다. 어떻게 수정해야합니까?
비디오 https://drive.google.com/file/d/0B0EJbcHq3ZALUVRzanJ6SndscWc/view
예 매우 커서 코드를 단순화했습니다. 내 코드에 NSProgress를 올바르게 추가하는 방법을 보여줄 수 있습니까? – wefagaefesfsefsef
우수한 WWDC 2015 비디오 [진행보고를위한 우수 사례] (https://developer.apple.com/videos/play/wwdc2015/232/)를 참조하십시오. – Rob