2

我有两个值 targetValue 和 receivedValue 。现在我想在进度条上显示状态。表示如果 targetValue 为 1000 且 receivedValue 为 500,则进度条应显示填充区域的 50%。

所以我想知道有什么简单的方法可以做到这一点......或者我必须计算任何必须设置的值myProgressBar.progress = value

4

3 回答 3

8

下面使用

myProgressBar.progress = receivedValue /targetValue ;

的值receivedValue /targetValue将在 0.0 到 1.0 的范围内;

于 2011-04-08T10:05:09.060 回答
2

ofcorse你必须计算价值并通过它。

myProgressBar.progress = value
于 2011-04-08T09:58:51.747 回答
0

这是我推荐的解决方案:

-(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];
    }    
}
于 2011-09-23T10:59:27.563 回答