展开和折叠动画在ios6中不起作用
问题描述:
我正在致力于UIView
。此按钮点击时展开并折叠。它在上工作iOS < = 5但不工作iOS6。你能否纠正我的代码或解释它。展开和折叠动画在ios6中不起作用
谢谢。
我的代码:
CGFloat x= 60,y = 391,w1=210,h1=48;
[ViewShare setHidden:YES];
[UIView beginAnimations:@"animationOff" context:NULL];
[UIView setAnimationDuration:0.2f];
[ViewShare setFrame:CGRectMake(x, y, w1, h1)];
[UIView commitAnimations];
而且Ref Page
谢谢..
答
嘛呢,你应该使用基于块的动画代替,因为使用提交动画的的iOS 4.0后气馁。
如果您尝试跨越很多IOS并尝试使用“不推荐使用”的方法,则会出现很多GUI bug代码。顺便说一下你的代码是正确的。
如果没有4.0之前使用IOS,改用
animateWithDuration:animations:completion:
下面是一个例子:
[UIView animateWithDuration: 0.2f
animations:^{
[ViewShare setFrame:CGRectMake(60, 391, 210, 48)];
}
completion:^(BOOL finished){
// what you want when the animation is done
}];
注意,有时,你需要根据IOS版本切换行为,它是非常总是与GUI相关。这让我非常紧张。 :)
你在哪里隐藏“ViewShare”? – shabbirv 2013-03-05 08:30:58
其视图名称... 隐藏在视图中 – Mani 2013-03-05 08:32:12
如果隐藏,动画将不起作用。如果您将ViewShare设置为隐藏在 – shabbirv 2013-03-05 08:35:49