0
我使用一些简单的UIAnimation属性来显示和隐藏UIView。这段代码似乎第一次完美地工作。但之后,动画效果并未被看到。有没有什么即时通讯在这段代码做错了..我张贴我的代码在这里..请纠正我,如果我的代码是不正确的,请建议我一个正确的做法。谢谢。UIAnimation似乎不能有效地工作
-(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;
}
}
@ mmccomb:thanku for ur answer bro ..我编辑了我的代码并发布了完整的代码片段..事实上,我在设置singleTapViewIsShowing = NO ...请查看我的代码...我已经通过在这个方法中加入了一些断点来检查我的代码..控件在这里输入,但是动画效果没有被看到...... – 2011-03-12 13:08:28
尝试更改'[UIView setAnimationTransition:UIViewAnimationCurveEaseInOut forView:singleTapView cache:YES];'to '[UIView setAnimationTransition:UIViewAnimationCurveEaseInOut forView:self.view cache:YES];'在这两个动画块中 – mmccomb 2011-03-12 16:32:23
@ mmccomb:hey bro ..我在这里改变了我的策略......我决定在代码片段中使用alpha属性它为我工作。我设置singleTapView.alpha = 1,然后将其更改回0,它为我工作。感谢您的帮助。干杯... – 2011-03-13 13:13:01