UISlider in UIBarButtonItem impacts animation behavior

為{幸葍}努か 提交于 2019-12-24 19:03:09

问题


In IB, I set a view MyView with an UIToolBar and I drop an UISlider on it. IB automatically embeds it in an UIBarButtonItem and sets its view with the UISlider.

I display this MyView in a navigation controller with animation.

UIViewController *myVC = [[UIViewController alloc] initWithNibName:@"MyView" bundle:nil];
[self.navigationController pushViewController:myVC animated:YES];
[myVC release];

MyView is displayed but without animation. Apart from that, everything works fine, I can use the UISlider as needed. If I remove the UISlider from the toolbar or if I put the UISlider in the view itself, not in the toolbar, MyView is displayed with animation. I have tried the same with an UIProgressView instead and it worked fine ( view is displayed with animation ). It seems that UISlider as customView of an UIBarButtonItem prevents the animation. I have also checked for any possible leaking.

Any idea ? Thanks Tart.


回答1:


I ran into exactly the same issue. I would open the view with the UISlider and from that point on, none of the view transitions in my application would be animated.

I ended up replacing the UIToolBar with a generic UIView (sounds like you've already tried this with success). You could always fake the UIToolBar look by capturing an image of an empty toolbar and using that as the background in your view.



来源:https://stackoverflow.com/questions/1771241/uislider-in-uibarbuttonitem-impacts-animation-behavior

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