cocos2d-x 横竖屏切换崩溃BUG

cocos2d默认的是横屏,找到ios6.0横竖屏切换响应的函数

1
2
3
4
5
6
7
8
9
10
11
12
// Only valid for iOS 6+. NOT VALID for iOS 4 / 5.
-(NSUInteger)supportedInterfaceOrientations {
                                                                                                                                                                                                                                            
    // iPhone only
    if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone )
        return UIInterfaceOrientationMaskPortrait;
                //return UIInterfaceOrientationMaskLandscape;
                                                                                                                                                                                                                                            
    // iPad only
    return UIInterfaceOrientationMaskPortrait;
    //return UIInterfaceOrientationMaskLandscape;
}

修改后,程序却意外的崩溃。

解决方案

在AppDelegate.m的AppController类下添加函数:

1
2
3
4
5
//解决ios6.0横竖屏切换程序崩溃问题
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    return UIInterfaceOrientationMaskAll;
}



你可能感兴趣的:(cocos2d-x 横竖屏切换崩溃BUG)