现在的位置: 首页 > 综合 > 正文

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

2013年10月03日 ⁄ 综合 ⁄ 共 662字 ⁄ 字号 评论关闭

转载地址: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;
}

抱歉!评论已关闭.