将GameCenter添加到横向专用的cocos2d应用程序后,iOS 6中出现错误

我遇到了这里描述的问题: https ://devforums.apple.com/thread/165384?tstart = 0我的应用程序崩溃试图加载GameCenterlogin屏幕,因为屏幕是纵向的,我的应用程序只支持横向。 我已经尝试了上述线程中描述的每个解决scheme以及以下线程上的所有解决scheme: 在iOS 6.0下呈现UIImagePickerController时出现崩溃以及此处: http : //www.cocos2d-iphone.org/forum/topic/36639

没有解决scheme的工作。 无论是崩溃仍然发生,或login工作正常,我的应用程序然后自由旋转之间的风景和肖像,或locking自己的肖像,并拧了整个用户界面。

我想要的是GameCenterlogin工作在纵向,然后在应用程序中的其他一切发生在横向。

这里是我的应用程序中包含的所有旋转方法。 这些是来自appdelegate.m中的myNavigationController实现的:

-(NSUInteger)supportedInterfaceOrientations { // iPhone only if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ) return UIInterfaceOrientationMaskLandscape; // iPad only return UIInterfaceOrientationMaskLandscape; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // iPhone only if( [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ) return UIInterfaceOrientationIsLandscape(interfaceOrientation); // iPad only // iPhone only return UIInterfaceOrientationIsLandscape(interfaceOrientation); } -(BOOL)shouldAutorotate{ return NO; } 

从appDelegate.m中的AppController实现:

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

包含在RootViewController.m中:

  -(BOOL)shouldAutorotate{ return NO; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeRight|UIInterfaceOrientationMaskLandscapeLeft; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandscapeRight; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return NO; } #if GAME_AUTOROTATION==kGameAutorotationNone return ( interfaceOrientation == UIInterfaceOrientationPortrait ); #elif GAME_AUTOROTATION==kGameAutorotationCCDirector if( interfaceOrientation == UIInterfaceOrientationLandscapeLeft ) { [[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeRight]; } else if( interfaceOrientation == UIInterfaceOrientationLandscapeRight) { [[CCDirector sharedDirector] setDeviceOrientation: kCCDeviceOrientationLandscapeLeft]; } #elif GAME_AUTOROTATION == kGameAutorotationUIViewController #else #error Unknown value in GAME_AUTOROTATION #endif // GAME_AUTOROTATION // Shold not happen return NO; } kGameAutorotationUIViewController #if GAME_AUTOROTATION == kGameAutorotationUIViewController -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { CGRect screenRect = [[UIScreen mainScreen] bounds]; CGRect rect = CGRectZero; if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) rect = screenRect; else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight){ rect.size = CGSizeMake( screenRect.size.height, screenRect.size.width ); } CCDirector *director = [CCDirector sharedDirector]; UIView *glView = [[CCDirector sharedDirector] view];; float contentScaleFactor = [director contentScaleFactor]; if( contentScaleFactor != 1 ) { rect.size.width *= contentScaleFactor; rect.size.height *= contentScaleFactor; } glView.frame = rect; } #endif // GAME_AUTOROTATION == kGameAutorotationUIViewController 

前几天刚刚回答了这个问题: Cocos 2d 2.0应该不行吗?

有关于你需要做什么才能得到这个答案的说明。 希望这可以帮助!