【问题标题】:iOS 6 landscape orientation problemsiOS 6 横向问题
【发布时间】:2013-02-23 10:27:41
【问题描述】:

在 iOS 中,关闭模态视图控制器(强制仅以纵向显示)后,如果设备处于横向模式,则呈现模态视图控制器的视图控制器不会旋转回风景正确。

'willAnimateRotationToInterfaceOrientation' 方法被调用,所以我可以管理我的子视图等的旋转,但是实际的视图控制器不会旋转到横向。所以我的子视图看起来应该是横向的,但界面是纵向模式。

令人讨厌的是它在 iOS 5 模拟器中运行良好。 IE。关闭模态视图控制器后,呈现的视图控制器旋转回横向。

有没有人经历过类似的事情,或者知道如何解决这个问题?

【问题讨论】:

  • 在 iOS 6 中,您拥有管理方向的新方法 shouldAutorotatesupportedInterfaceOrientationspreferredInterfaceOrientationForPresentation

标签: iphone ios objective-c orientation uiinterfaceorientation


【解决方案1】:

对于 IOS 6,您需要使用此方法处理方向。

- (BOOL)shouldAutorotate; {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations; {
    if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
        return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
    }
    else{
        return UIInterfaceOrientationMaskLandscape;
    }
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation; {
    if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
        return UIInterfaceOrientationPortrait;
    }
    else{
        return UIInterfaceOrientationLandscapeLeft;
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    相关资源
    最近更新 更多