ios中的cocos2d方向问题< = 6

时间:2013-01-15 08:39:16

标签: iphone ios objective-c cocos2d-iphone

我开发的游戏仅支持横向模式,比ios 4.3设备更高。 应用程序在ios 6设备上测试期间实施并崩溃了游戏中心,因为游戏中心登录界面不支持ios 6中的横向模式。 所以我修复了问题,将下面的代码添加到appdelegate.m并开始工作,但现在应用程序显示在ios6(ios5等)以下的设备上完全连线(显示纵向颠倒)

-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        return UIInterfaceOrientationMaskAll;
    else // iphone
        return UIInterfaceOrientationMaskAllButUpsideDown;
}

使用 Xcode中:4.5 cocos2d v1.0.1

请帮我解决这个问题

2 个答案:

答案 0 :(得分:1)

在项目中添加给定的课程

GKMatchmakerViewController-LandscapeOnly.h

#import <Foundation/Foundation.h>
#import <GameKit/GameKit.h>

@interface GKMatchmakerViewController(LandscapeOnly)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
@end

GKMatchmakerViewController-LandscapeOnly.m


#import "GKMatchmakerViewController-LandscapeOnly.h"

@implementation GKMatchmakerViewController (LandscapeOnly)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );
}

@end

答案 1 :(得分:0)

替换这行代码[window addSubview:viewController.view]; AppDelegate.m中有一个以下

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

在RootViewController.m中添加以下代码

///////********************************/////////

// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead of shouldAutorotateToInterfaceOrientation

- (NSUInteger) supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}

- (BOOL) shouldAutorotate {
    return YES;
}

///////********************************/////////