开发者

UIAnimation seems to be not working effectively

i'm using some simple UIAnimation properties to show and hide a UIView. This code seems to work perfectly for the very first time. But after that the animation effect is not being seen. is there anything im doing wrong in this code.. Im posting my code here.. Please correct me if my code is incorrect and please suggest me a correct approach. Thank you.

-(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;

}

}


You say that the animation works the first time but subsequently doesn't run. Are you setting your sigleTapViewIsShowing to NO anywhere else in your code? Of you're not the animation will trigger for the first time and execute...

singleTapViewIsShowing=YES;

This will stop any the animation running until you reset this flag elsewhere. Are you?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜