0

我正在使用一些简单的 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;

}

}

4

1 回答 1

0

您说动画第一次运行但随后没有运行。您是否在代码中的其他任何地方将您的 sigleTapViewIsShowing 设置为 NO?你不是动画会第一次触发并执行......

singleTapViewIsShowing=YES;

这将停止任何动画运行,直到您在其他地方重置此标志。你是?

于 2011-03-12T11:54:10.313 回答