UISlider not animating in iOS7

大城市里の小女人 提交于 2020-01-03 06:44:09

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/19055645/uislider-not-animating-in-ios7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!