Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISlider not animating in iOS7

When I switched from iOS 6 to iOS 7 design, I noticed that using the method setValue:animated: no longer animates the sliding process. Has anyone else came across this problem and found a solution?

I'll just add some code to show I've done nothing complicated:

//Variable declaration IBOutlet UISlider *s; //Connected in the .xib  //Button pressed - (IBAction)buttonPressed:(id)sender {     [s setValue:1 animated:YES]; } 

And it jumps straight to 1 after I press the button.

like image 647
Flying_Banana Avatar asked Sep 27 '13 16:09

Flying_Banana


1 Answers

Backwards compatible to iOS 4 solution/workaround:

[UIView animateWithDuration:1.0 animations:^{     [_sliderTest setValue:0.90 animated:YES]; }]; 

It seems that iOS 7 wont animate unless you specify both this block and animated:YES. iOS 6.0 seems to ignore the animation block and execute its own internal block. Kinda odd. Specify a duration of 2.0 to see iOS 7 animate twice as slow as iOS 6 with the same code.

like image 115
MechEthan Avatar answered Sep 24 '22 04:09

MechEthan