RootViewController动画过渡,初始方向错误 [英] RootViewController animation transition, initial orientation is wrong

查看:101
本文介绍了RootViewController动画过渡,初始方向错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我按照这个主题: RootViewController切换过渡动画来传递window.rootViewController A到B到C.代码如下所示:

So I followed this thread: RootViewController Switch Transition Animation to transit the window.rootViewController from A to B to C. Code looks like this:

[UIView transitionWithView:self.window 
                  duration:0.5 
                   options: UIViewAnimationOptionTransitionFlipFromLeft 
                animations:^{
                               self.window.rootViewController = newViewController;
                } 
                completion:nil];

问题是我的应用程序只支持格局,但在rootViewController过渡期间,会出现新的视图控制器在纵向模式下比快速旋转到横向模式。

The problem is my app shall only support landscape, but during the rootViewController transition, the new view controller appears in portrait mode than quickly rotate to landscape mode.

我确定:


  1. 我为每个viewcontroller设置了UISupportedOrientation为横向(主页按钮右侧)

  2. ,在shouldAutoRotateToOrientation方法中,我只设置为横向

可能是另一个原因?

推荐答案

我调查了这个现在,因为我一直在遇到同样的问题。我随机尝试了以下内容,它运行得很好:

I looked into this just now because I kept getting the same issue. I randomly tried the following, and it worked perfectly:

[UIView
    transitionWithView:window 
    duration:0.5
    options:UIViewAnimationOptionTransitionCrossDissolve
    animations:^(void) {
        BOOL oldState = [UIView areAnimationsEnabled];
        [UIView setAnimationsEnabled:NO];
        [(ICApp *)sharedApplication.delegate window].rootViewController = self;
        [UIView setAnimationsEnabled:oldState];
    } 
    completion:nil];

我知道在动画块中禁用/启用动画有点奇怪,但交叉消解动画,旋转没有 - 视图控制器似乎已经旋转并准备好滚动。

I know it's a bit odd to disable/enable animations inside an animation block, but the cross dissolve animates, and the rotation does not -- the view controller appears already rotated and ready to roll.

这篇关于RootViewController动画过渡,初始方向错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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