翻转视图动画不起作用 [英] Flip View Animation Not Working

查看:84
本文介绍了翻转视图动画不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款iPad应用,可在视图中向用户提问。当他们回答问题时,我希望视图转换到包含下一个问题的另一个视图。为了使它看起来很奇特,我试图添加一个curl过渡到它,但我写的代码不起作用,我不能看到找到问题。它确实显示正确的视图,但没有过渡动画。那是什么?以下是我用来转换的方法:

I am working on an iPad app that presents a question to the user in a view. When they answer the question, I would like the view to transition to another view that contains the next question. To make it look all fancy, I am trying to add a curl transition to it but the code I wrote does not work can I can't see to find the problem. It does show the correct view but there is no transition animation. What's with that? Here is the method I use to transition:

- (void)pageChangedTo:(NSInteger)page {

    if ( (page == currentQuestionNumber) || (page > ( [self.allQuestions count] - 1 ) ) || (page < 0) ) {
        return;
    }

    AskQuestionView *view = [self.questionViews objectAtIndex:page];

    UIViewAnimationTransition transition;
    if (page > currentQuestionNumber) {
        transition = UIViewAnimationTransitionCurlUp;
    }
    else {
        transition = UIViewAnimationTransitionCurlDown;
    }

    if (self.containerView1.superview) {

        self.containerView2 = view;
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:1.0];
        [UIView setAnimationTransition:transition forView:self.containerView1 cache:YES];
        [self.containerView1 removeFromSuperview];
        [askQuestionsView addSubview:self.containerView2];
        [UIView commitAnimations];
    }
    else {
        self.containerView1 = view;
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:1.0];
        [UIView setAnimationTransition:transition forView:self.containerView2 cache:YES];
        [self.containerView2 removeFromSuperview];
        [askQuestionsView addSubview:self.containerView1];
        [UIView commitAnimations];
    }

    currentQuestionNumber = page;
}

谁能告诉我为什么这不起作用?我非常感谢!

Can anyone tell me why this isn't working? I would very much appreciate it!

推荐答案

为View:_ _self的容器设置动画过渡。 containerView2:不是被删除的那个,而是被删除的那个。

Set your animation transition forView: _container of_self.containerView2: not the one that's being removed, but the one it's being removed from.

这篇关于翻转视图动画不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆