Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISlider behaviour in iOS7 versus iOS6

Tags:

ios

uislider

I noticed that UISlider in iOS7 behaves differently than it did in iOS 6 and iOS 5:

Say you have a slider with min=0 and max=10, current value is 0. When you first touch the "knob", a valueChanged message is sent with slider.value=0.269 (instead of the expected 0) and the knob moves towards the middle. Generally, touching the slider moves it towards the middle value (5 in this example), the farther out from the middle it currently is, the more it moves.

All this did not happen in iOS6, and I'd like to restore the old behaviour, but have no idea how to achieve this.

like image 532
Gereon Avatar asked Jan 03 '14 12:01

Gereon


1 Answers

On iOS 9 you need to set for .Normal, .Selected and .Highlighted states to work. I found this after 5h of struggling. Way to go Apple!

[_sliderView setThumbImage:[UIImage imageNamed:@"knob"] forState:UIControlStateNormal];
[_sliderView setThumbImage:[UIImage imageNamed:@"knob"] forState:UIControlStateSelected];
[_sliderView setThumbImage:[UIImage imageNamed:@"knob"] forState:UIControlStateHighlighted];
like image 74
Josip B. Avatar answered Sep 18 '22 20:09

Josip B.