如何在弹出视图控制器上执行翻转动画?

时间:2011-03-30 17:37:40

标签: iphone objective-c core-animation

我有一个翻转动画,如下所示:

Picker *picker = [[Picker alloc] init];

            [self.navigationController pushViewController:picker animated:NO];

            [UIView animateWithDuration:0.5
                             animations:^{ 
                                 [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
                                 } 
                             completion:^(BOOL finished){
                             }];
            [picker release];

这完美无缺。但是当我想让popViewController回来时,就像这样:

[self.navigationController popViewControllerAnimated:NO];

    [UIView animateWithDuration:0.5
                     animations:^{ 

                         [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
                     } 
                     completion:^(BOOL finished){
                     }];

但是这不起作用,只是在没有动画的情况下回到视图。

2 个答案:

答案 0 :(得分:6)

您是否尝试在动画结束后调用popViewControllerAnimated

答案 1 :(得分:0)

将popViewController调用放入完成块中,使其先设置动画然后弹出。