Reputation: 19418
I am having two values targetValue and receivedValue . Now I want to show the status on Progress bar. Means if targetValue is 1000 and receivedValue is 500 then progress bar should display 50% of filled area.
So I want to know that is there any easy way to do so... or I have to calculate the values any have to set with myProgressBar.progress = value
?
Upvotes: 2
Views: 4868
Reputation: 202
Here is a solution I recommend:
-(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];
}
}
Upvotes: 0
Reputation: 31722
Use below
myProgressBar.progress = receivedValue /targetValue ;
The value of receivedValue /targetValue
will fall in the range of 0.0 to 1.0 ;
Upvotes: 8
Reputation: 4606
ofcorse you have to calculate value and pass it.
myProgressBar.progress = value
Upvotes: 2