2

我有一个 UIProgressView,我用它来直观地表示一分钟计时器。它的宽度为 280 像素。我正在使用 NSTimer 逐渐减小“进度”的值,从进度 = 1.0 开始。“进度”每十分之一秒更新一次。除了最后两秒钟,它完全按照我的意愿行事。

一旦“进度”的值低于 0.03,UIProgressView 的移动就会停止(显示大约 0.2 厘米的条形图),直到“进度”达到 0.0,此时 0.2 厘米的条形图就会消失。

有谁知道为什么 UIProgressView 会这样?这是设计使然,还是我做错了什么?

编辑:

月,

我不认为它与舍入有关,因为在 NSTimer 调用的方法中,我使用 NSLog 来显示“进度”的值,并且它打印有六个有效数字,例如

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

此外,如果是这样的话,所有的动作都会是波涛汹涌的,不仅仅是最后两秒钟。这是 NSTimer 调用的代码:

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

3 回答 3

2

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.

于 2010-01-01T20:29:30.617 回答
0

它与您的进度量的四舍五入或计算有什么关系吗?你能展示一下代码,以便我们看一下。可能只是进度变量本身被计算为 0.3。

您是否在运行时检查以确保您的进度变量更新为 0.2 或 0.1 等?

于 2010-01-01T01:54:10.470 回答
0

如果您(和 Apple)不介意颜色颠倒,您可以水平翻转视图并将其开始为空并逐渐填充它。它将有同样的问题,但在开始而不是结束。

于 2010-01-21T04:10:15.907 回答