Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having the UIControlEventValueChanged fire when UISlider is being animated?

I have set my UISlider up to respond to value changed events:

[customSlider addTarget:self action:@selector(sliderMove:) forControlEvents:UIControlEventValueChanged];
[customSlider addTarget:self action:@selector(sliderStart:) forControlEvents:UIControlEventTouchDown];
[customSlider addTarget:self action:@selector(sliderEnd:) forControlEvents:UIControlEventTouchUpInside];

I would like to animate the slider to the position where the user left it the last time the view was used. I do this with:

[customSlider setValue:position animated:YES];

Everything works fine, except, I have build a "tag" that hangs over the sliders "knob" so the user can see the value when moving the slider. The position of the "tag" is set when the UIControlEventValueChanged calls the "sliderMove" method.

When using the [slider setValue:position animated:YES] the slider moves, but the event does not fire.

Is there a delegate I can get to or an event that covers this scenario?

Thanks for any help given:)

like image 266
RickiG Avatar asked May 12 '10 15:05

RickiG


1 Answers

Sounds like a bug, try to workaround this by calling

[slider sendActionsForControlEvents:UIControlEventValueChanged];

right after you set the value programmatically.

like image 144
bddckr Avatar answered Sep 23 '22 12:09

bddckr