iOS 6横向定位问题

时间:2013-03-08 00:19:26

标签: iphone ios objective-c orientation uiinterfaceorientation

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

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

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

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

1 个答案:

答案 0 :(得分:0)

对于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;
    }
}