强制iOS界面方向

时间:2015-08-25 14:34:36

标签: ios iphone cocoa-touch

我可以通过几个技巧来改变轮换(例如,调用[[UIDevice currentDevice] setValue:rotation forKey:@"orientation"];,或者使用想要的旋转方法覆盖UIViewController,并在不久之后解除它。)

问题,当我在手机上禁用旋转锁定,并将手机旋转到想要的旋转时,在UIViewController不支持,但不支持,但移动到支持此旋转的UIViewController(通过弹出窗口),旋转未正确应用。

有任何想法如何解决这个问题?

1 个答案:

答案 0 :(得分:-1)

我想我明白你在问什么,我之前遇到过这个问题。我把它放在了弹出的视图控制器中解决了:

-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];

    if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
        [[UIDevice currentDevice]performSelector:@selector(setOrientation:) withObject:(__bridge id)((void *)UIInterfaceOrientationPortrait)];
    }
}