Objective c 如何在过渡时不停止动画而过渡到modalViewController

Objective c 如何在过渡时不停止动画而过渡到modalViewController,objective-c,ios,uiviewcontroller,core-animation,uiviewanimation,Objective C,Ios,Uiviewcontroller,Core Animation,Uiviewanimation,我注意到,如果我在控制器“a”的某个元素上启动UIView动画,并向控制器B显示过渡,则先前提交的动画不会启动。 例如: //apply a UIView animation before transitioning [UIView animateWithDuration: 1 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ someUIView.frame = newFram

我注意到,如果我在控制器“a”的某个元素上启动UIView动画,并向控制器B显示过渡,则先前提交的动画不会启动。 例如:

//apply a UIView animation before transitioning
[UIView animateWithDuration: 1 delay:0 options:UIViewAnimationOptionCurveEaseOut             animations:^{
        someUIView.frame = newFrame;
 }completion:nil];
//transition from  controller A to controller B
controllerB.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController: controllerB animated:YES];
如果动画已经开始,并且我尝试转换到控制器B,则A中的动画将停止。我注意到这种行为取决于所使用的转换类型。例如,如果使用“UIModalTransitionStyleCoverVertical”,则不会出现问题。
有什么想法吗?

只需从动画完成块中显示您的控制器B即可

[UIView animateWithDuration: 1 
                      delay:0
                    options:UIViewAnimationOptionCurveEaseOut
                 animations:^{
                     someUIView.frame = newFrame;
                }completion:^{
                   //transition from  controller A to controller B
                   controllerB.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
                   [self presentModalViewController: controllerB animated:YES];
 }];

只需从动画完成块中显示控制器B

[UIView animateWithDuration: 1 
                      delay:0
                    options:UIViewAnimationOptionCurveEaseOut
                 animations:^{
                     someUIView.frame = newFrame;
                }completion:^{
                   //transition from  controller A to controller B
                   controllerB.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
                   [self presentModalViewController: controllerB animated:YES];
 }];

你确定它不会启动吗?也许,你只是错过了!因为如果它发生在一个过渡样式中,它也应该发生在其他过渡样式中…我确信它不会开始。如果它已经开始,它将在转换开始时停止。试试看;)同时在iPhone模拟器中打开“慢速动画”。嗯……我想我明白它为什么停止了。请参见,在
UIModalTransitionStyleCoverVertical
中,主视图的层未被触及。在其他过渡样式中,将对主视图的层拍摄快照,并在该快照/层上执行过渡动画。所以它正在发生,但您只能看到在动画开始之前创建的层。这就是过渡动画的工作原理,所以我认为这应该是对这种异常现象的解释。快照不会改变以反映正在进行的动画,因此我们无法看到它发生。@tipycalFlow这是一个很好的解释。情况可能就是这样。不幸的是,当键盘在从一个控制器转换到另一个控制器时显示/隐藏时,使用UIview动画移动元素时,“冻结”动画看起来不是很好。但我想除了使用不需要对层进行快照(或光栅化)的转换之外,我无能为力。你确定它不会启动吗?也许,你只是错过了!因为如果它发生在一个过渡样式中,它也应该发生在其他过渡样式中…我确信它不会开始。如果它已经开始,它将在转换开始时停止。试试看;)同时在iPhone模拟器中打开“慢速动画”。嗯……我想我明白它为什么停止了。请参见,在
UIModalTransitionStyleCoverVertical
中,主视图的层未被触及。在其他过渡样式中,将对主视图的层拍摄快照,并在该快照/层上执行过渡动画。所以它正在发生,但您只能看到在动画开始之前创建的层。这就是过渡动画的工作原理,所以我认为这应该是对这种异常现象的解释。快照不会改变以反映正在进行的动画,因此我们无法看到它发生。@tipycalFlow这是一个很好的解释。情况可能就是这样。不幸的是,当键盘在从一个控制器转换到另一个控制器时显示/隐藏时,使用UIview动画移动元素时,“冻结”动画看起来不是很好。但我想除了使用不需要对层进行快照(或光栅化)的转换之外,我无能为力。