Iphone 旋转iOS 6兼容iOS 5

Iphone 旋转iOS 6兼容iOS 5,iphone,ios5,rotation,ios6,Iphone,Ios5,Rotation,Ios6,我正在开发一个应用程序(Xcode 4.5 iOS 6),它必须与安装了软件版本的设备兼容,从4.5和默认的iPhone 5开始。 我知道新的iOS 6的变化伴随着自动旋转模式 当您打开设备时,“iPhone Simulator 6.0”应用程序运行正常,但当我运行“iPhone Simulator 5.0”时,会出现旋转问题 我加入了代码,以及从iOS 6和旧方法(已弃用)到iOS 5的新方法 因此,请查看旋转方法: #pragma mark - Rotate Methods - (NSU

我正在开发一个应用程序(Xcode 4.5 iOS 6),它必须与安装了软件版本的设备兼容,从4.5和默认的iPhone 5开始。

我知道新的iOS 6的变化伴随着自动旋转模式

当您打开设备时,“iPhone Simulator 6.0”应用程序运行正常,但当我运行“iPhone Simulator 5.0”时,会出现旋转问题

我加入了代码,以及从iOS 6和旧方法(已弃用)到iOS 5的新方法

因此,请查看旋转方法:

#pragma mark - Rotate Methods

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

- (BOOL) shouldAutorotate
{
   return YES;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationPortrait;
}

#pragma mark - Rotate Methods iOS 5

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (UIInterfaceOrientationIsPortrait(interfaceOrientation))
    {
        [menuPortrait setHidden:NO];
        [menuLandscape setHidden:YES];
    }

    if (UIInterfaceOrientationIsLandscape(interfaceOrientation))
    {
        [menuPortrait setHidden:YES];
        [menuLandscape setHidden:NO];
    }
    return YES;
}

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
        if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation))
        {
            [self.menuLandscape setHidden:YES];
            [self.menuPortrait  setHidden:NO];
        }
        if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation))
        {
            [self.menuLandscape setHidden:NO];
            [self.menuPortrait setHidden:YES];
        }

    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
}

关于这个问题,你能帮我提些建议吗!提前感谢您的回答

我通过如下子类化所有视图控制器来实现它:

//h #进口

@interface ITViewController : UIViewController

@end
//m


这将强制横向定位模式。您可以更新这两种方法的内容,以符合所需的行为

我遇到了相同的问题。我哪儿都找不到。你能在哪里解决这个问题?我有一个UISplitViewController作为根视图,我在其中添加了你的iOS 5方法,现在它可以正常旋转。你的问题一定和我的不同,但是谢谢。我解决了这个问题,现在我的代码对iOS 6和iOS 5来说是OK的:#pragma标记-旋转方法-(BOOL)应该自动旋转{return YES;}-(UIInterfaceOrientation)preferredinterfaceorientation for presentation{return UIInterfaceOrientation纵向;}-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{return YES;}-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation持续时间:(NSTimeInterval)持续时间{[super willRotateToInterfaceOrientation:toInterfaceOrientation:duration];}
#import "ITViewController.h"

@interface ITViewController ()

@end

@implementation ITViewController


- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
}