使用动画交换rootViewController [英] Swapping rootViewController with animation

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

问题描述

我有一个麻烦,用动画交换rootViewControllers。这里是我使用的代码:

I'm having a little trouble swapping rootViewControllers with animation. Here's the code that I'm using:

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

这种工作除了在动画之前,屏幕变成黑色,然后动画发生。它看起来像原来的rootViewController正在动画之前被删除。任何想法?

It kind of works except that right before the animation, the screen turns to black and then the animation occurs. It looks like the original rootViewController is getting removed right before the animation. Any ideas?

推荐答案

transitionWithView 容器视图。动画改变根视图控制器并不简单。我花了很长时间试图做它w / o副作用。请参阅:

transitionWithView is intended to animate subviews of the specified container view. It is not so simple to animate changing the root view controller. I've spent a long time trying to do it w/o side effects. See:

更改视图控制器而不使用导航控制器堆栈,子视图或模态控制器?

编辑:从引用的回答

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

这篇关于使用动画交换rootViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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