使用动画交换rootViewController [英] Swapping rootViewController with animation
问题描述
我有一个麻烦,用动画交换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屋!