gpt4 book ai didi

objective-c - 如何在过渡时不停止动画的情况下过渡到 modalViewController

转载 作者:行者123 更新时间:2023-12-01 16:56:48 25 4
gpt4 key购买 nike

我注意到,如果我在 Controller “A”的某个元素上启动 UIView 动画并呈现带有过渡的 Controller 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];

如果动画已经开始并且我尝试转换到 Controller B,则 A 中的动画将停止。我注意到这种行为取决于使用的转换类型。例如,如果使用“UIModalTransitionStyleCoverVertical”,则不会出现问题。
有什么想法吗?

最佳答案

只需从动画完成 block 中展示您的 Controller 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];
}];

关于objective-c - 如何在过渡时不停止动画的情况下过渡到 modalViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10983700/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com