Cocos2d-x学习(十九):iOS6中无法正常游戏横屏的解决方案

转载地址:http://www.himigame.com/iphone-cocos2dx/1000.html


1.先在项目的ios目录下的AppController.mm文件中的
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 

方法中

// Set RootViewController to window
[window addSubview: viewController.view];

替换为

// Set RootViewController to window
 if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
 {
     // warning: addSubView doesn't work on iOS6
     [window addSubview: viewController.view];
 }
 else
 {
     // use this mehod on ios6
    [window setRootViewController:viewController];
}

2.在ios目录的RootViewController中添加两个方法

- (NSUInteger) supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}
 
- (BOOL) shouldAutorotate {
    return YES;
}



你可能感兴趣的:(Cocos2d-x学习(十九):iOS6中无法正常游戏横屏的解决方案)