【发布时间】:2013-06-25 15:44:13
【问题描述】:
我有一个简单的动画:
- (void)showMenu
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
self.scrollView.frame = CGRectMake(296, -150, 432, 356);
[self.buttonMenu setImage:[UIImage imageNamed:@"menu_arrow_up.png"] forState:UIControlStateNormal];
[self.view bringSubviewToFront:self.scrollView];
[UIView commitAnimations];
}
当我第一次调用这个动画时,只是我按钮的图像发生了变化, 我的滚动视图的位置没有改变。
在我两次调用showMenu 方法后,一切正常。
- 我打电话给
showMenu。按钮的图像发生变化。scrollview的位置不是 - 我调用了另一种方法来重置所有内容。按钮更改的图像。
scrollview的位置不是 - 我打电话给
showMenu。按钮的图像发生变化。scrollview的位置发生变化 - 从现在开始,每次我拨打
showmenu时它都会起作用
第二种方法是closeMenu:
- (void)closeMenu
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
self.scrollView.frame = CGRectMake(296, -317, 432, 356);
[self.buttonMenu setImage:[UIImage imageNamed:@"menu_arrow_down.png"] forState:UIControlStateNormal];
[UIView commitAnimations];
}
那为什么我点击两次它就起作用了?
【问题讨论】:
-
是的,自动布局已开启
-
但为什么第二次使用后它仍然有效?即使我重新加载用户界面也没有问题和抱怨?
-
我建议不要使用自动布局。它最终比它的价值更痛苦
-
禁用自动布局解决了问题
标签: iphone ios uianimation