Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIProgressView with progress at low values issue

I'm running a progress bar which updates every second. It needs to run for upwards of 300 seconds so the changes in the progress bar's 'progress' variable are on the magnitude of about 0.003 per second.

I've noticed a problem with low values of the 'progress' variable, though. Basically, there does not seem to be any difference between 0.09 and anything lower than that. So what ends up happening is when the progress bar is in the 0.0 - 0.09 range it doesn't show any visual changes even though the progress variable is changing. Another side effect is if I start the progress bar from 0.0 it immediately jumps to the image for 0.09 or so (and remains there until the real progress has passed that), which looks a little odd.

It's probably worth mentioning that this doesn't seem to be an issue anywhere else along the progress bar. It's able to move the bar 0.003 progress at a time everywhere else, including very near to 1.0.

I suppose it's not a huge deal, but I was wondering if anyone knew a way around this.

Thanks in advance.

like image 724
user2371691 Avatar asked May 10 '13 22:05

user2371691


1 Answers

I'm aware this post is essentially dead, but I came up with a way to deal with it that doesn't involve multiple UIProgressViews.

I decided to simply forget UIProgressView altogether and write a fake one leveraging UISlider instead. I removed the knob with [setThumbImage:[UIImage new] forState:UIControlStateNormal] and disabled user interaction. From here, I did everything else similar to how the UIProgressView works except obviously conforming to how the slider handles its tracking.

I also subclassed UISlider to utilize (CGRect)trackRectForBounds:(CGRect)bounds so that I could set the track height to look more like a UIProgressView.

Hope this helps someone else.

like image 76
Stakenborg Avatar answered Oct 07 '22 16:10

Stakenborg