我有一个简单的动画:
- (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];
}
那么为什么只有当我单击它两次时它才起作用?