gpt4 book ai didi

objective-c - 用动画交换 rootViewController

转载 作者:IT王子 更新时间:2023-10-29 07:46:14 25 4
gpt4 key购买 nike

我在将 rootViewControllers 与动画交换时遇到了一些问题。这是我正在使用的代码:

[UIView transitionWithView:self.window duration:0.8 options:UIViewAnimationOptionTransitionFlipFromRight animations:^{
self.window.rootViewController = self.navigationController;
} completion:nil];

除了在动画播放之前,屏幕变黑然后动画出现之外,它有点工作。看起来原来的 rootViewController 在动画之前被删除了。有什么想法吗?

最佳答案

transitionWithView 旨在为指定容器 View 的 subview 设置动画。动画更改 Root View Controller 并不是那么简单。我花了很长时间尝试做到没有副作用。见:

Animate change of view controllers without using navigation controller stack, subviews or modal controllers?

编辑:添加引用答案的摘录

[UIView transitionFromView:self.window.rootViewController.view
toView:viewController.view
duration:0.65f
options:transition
completion:^(BOOL finished){
self.window.rootViewController = viewController;
}];

关于objective-c - 用动画交换 rootViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8827891/

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