2013-01-15 64 views
0

我開發的遊戲僅支持ios 4.3以上設備的橫向模式。 該應用程序在iOS設備上進行測試期間已實施並崩潰,因爲gamecenter登錄屏幕不支持ios 6中的橫向模式。因此,我解決了將以下代碼添加到appdelegate.m中並解決了問題,但現在應用程序完全顯示有線(顯示人像顛倒)下面iOS6的設備(的iOS5等)ios中的cocos2d定位問題<= 6

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

使用 的Xcode 4.5 的cocos2d 1.0.1

請幫我解決這個問題給出添加

回答

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 
+0

你能PLS解釋它是如何工作的?我是否需要在appdelegate或rootviewcontroller中調用此類? – Hassy31

+0

你剛剛創建這個文件,並在GCHelper類 –

+0

中調用GKMatchmakerViewController,如果有任何問題再次告訴我 –

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; 
} 

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