我有两个值 targetValue 和 receivedValue 。现在我想在进度条上显示状态。表示如果 targetValue 为 1000 且 receivedValue 为 500,则进度条应显示填充区域的 50%。
所以我想知道有什么简单的方法可以做到这一点......或者我必须计算任何必须设置的值myProgressBar.progress = value
?
我有两个值 targetValue 和 receivedValue 。现在我想在进度条上显示状态。表示如果 targetValue 为 1000 且 receivedValue 为 500,则进度条应显示填充区域的 50%。
所以我想知道有什么简单的方法可以做到这一点......或者我必须计算任何必须设置的值myProgressBar.progress = value
?
下面使用
myProgressBar.progress = receivedValue /targetValue ;
的值receivedValue /targetValue
将在 0.0 到 1.0 的范围内;
ofcorse你必须计算价值并通过它。
myProgressBar.progress = value
这是我推荐的解决方案:
-(void)UpdateProgressbar:(NSNumber*)currentOperationNumer TotalOperationNumber:(NSNumber*)n
{
NSLog(@" operation : %i", currentOperationNumer);
NSLog(@" total : %i", n);
NSString *inStr = [NSString stringWithFormat:@"%d", n];
NSLog(@"%@", inStr);
NSString *Str = [NSString stringWithFormat:@"%d", currentOperationNumer];
NSLog(@"%@", Str);
if (currentOperationNumer <= n) {
[downloadBar setProgress:([Str intValue]/[inStr floatValue])];
NSLog(@"progress !");
}
else {
[self.view removeFromSuperview];
}
}