我正在使用一些简单的UIAnimation属性来显示和隐藏UIView。这段代码似乎第一次完美运行。但之后没有看到动画效果。在这段代码中有什么我做错了。我在这里发布我的代码..请纠正我,如果我的代码不正确,请建议我一个正确的方法。谢谢。
-(IBAction)animateSingleTap:(UIButton*)sender{
NSLog(@"trying to animate singletap");
if(singleTapViewIsShowing==NO){
[searchController hideSelf];
[singleTapView sendSubviewToBack:hideSingleTapButton ];
hideSingleTapButton.frame=CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[UIView beginAnimations:@"single tap animation" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationTransition:UIViewAnimationCurveEaseInOut forView:singleTapView cache:YES];
[self.view addSubview:singleTapView];
hideSingleTapButton.frame=CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
[self.view bringSubviewToFront:singleTapView];
optionsButton.selected=YES;
singleTapViewIsShowing=YES;
singleTapView.frame=CGRectMake(sender.frame.origin.x-95, sender.frame.origin.y+30, singleTapView.frame.size.width, singleTapView.frame.size.height);
[UIView commitAnimations];
}
else {
[UIView beginAnimations:@"single tap animation" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationTransition:UIViewAnimationCurveEaseInOut forView:singleTapView cache:YES];
[singleTapView removeFromSuperview];
optionsButton.selected=NO;
[UIView commitAnimations];
singleTapViewIsShowing=NO;
}
}
答案 0 :(得分:0)
你说动画第一次运行但后来没有运行。您是否将代码中的sigleTapViewIsShowing设置为NO?你不是动画会第一次触发并执行...
singleTapViewIsShowing=YES;
这将停止任何动画运行,直到您在其他地方重置此标志。你呢?