cocos2dx 2.0+ 版本,IOS6.0+设置横屏

使用cocos2dx 自带的xcode模板,是不能正常的设置为横屏的。

一共修改了三个地方:

在项目属性中:Deployment Info中,勾选上 Landscape left,以及 Landscape Right(如果需要)

在 RootViewController.mm 中,添加上两个函数:

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
//    return UIInterfaceOrientationMaskPortrait;
}


-(BOOL)shouldAutorotate
{
    return YES;
}

在AppController.mm 中,将这一句

[window addSubview:__glView];

换成下面:

    NSString *reqSysVer = @"6.0";
    NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
    
    if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
    {
        [window setRootViewController:viewController];
    }
    else
    {
        [window addSubview:viewController.view];
    }

  

至此,OK。

看到网上,有的人只用了前两步就OK了,我设置到第三步才能正常设置横屏。

原文地址:https://www.cnblogs.com/cg-wang/p/3350681.html