views:

319

answers:

3

I have a UIProgressView that I'm using to visually represent a one-minute timer. Its width is 280 pixels. I'm using NSTimer to gradually decrease the value of 'progress', starting at progress=1.0. 'Progress' gets updated once every tenth of a second. For all but the final two seconds, it does exactly what I want it to.

Once the value of 'progress' goes below 0.03, the movement of the UIProgressView stops (showing about .2cm of bar) until 'progress' reaches 0.0, at which point the .2cm of bar simply disappears.

Does anyone know why UIProgressView is behaving this way? Is this by design, or am I doing something incorrectly?

edit:

mjdth,

I don't think it has to do with rounding, since in the method that NSTimer calls, I'm using NSLog to show the value of 'progress', and it gets printed with six significant digits, e.g.

2009-12-31 21:13:22.462 XXXXXXX 0.101669
2009-12-31 21:13:22.562 XXXXXXX 0.100003

Besides, if that were the case, all of the movement would be choppy, not just the last two seconds. Here is the code that NSTimer calls:

- (void) updateProgressBar {
    timerProgressBar.progress = [playEndTime timeIntervalSinceNow] / 60.0;
    NSLog(@"%f", timerProgressBar.progress);
}
A: 

Does it have anything to do with the rounding or calculating of your progress amount? Can you show the code for that so we can look at it. It might simply be that the progress variable itself is being calculated to 0.3.

Have you checked during runtime to make sure that your progress variable is updating to 0.2 or 0.1 etc?

mjdth
+1  A: 

I believe it's by design because the rounded end caps of the progress bar can't be drawn partially. Below a certain threshold, but above zero, just both the end caps are drawn, and only when it gets above a certain level does the middle part of the image get drawn and extended.

Would it work if you used the progress bar in its normal, forward direction? It can draw the last few seconds normally because it doesn't have that limitation at the other end.

lucius
A: 

If you (and Apple) don't mind the colors being reversed, you could flip the view horizontally and start it empty and gradually fill it up. It's going to have the same problem, but at the beginning instead of the end.

David Kanarek