@loseleo 写道:
用命令创建的lua新工程,设置为竖屏,调用gamecenter的登录就会闪退,log如下:
2016-09-25 16:48:49.827916 LuaGame iOS[4422:1139894] *** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [GKNotificationBannerViewController shouldAutorotate] is returning YES'
*** First throw call stack:
(0x18785c1c0 0x18629455c 0x18785c108 0x18d719334 0x18d718cc4 0x18d718a98 0x197c67f70 0x197c682bc 0x197c73204 0x197c72ef8 0x1969a597c 0x1969a4f40 0x187862160 0x187755c3c 0x1969f3aa0 0x1969e6954 0x101af925c 0x101af921c 0x101afe284 0x187809f2c 0x187807b18 0x187736048 0x1891b9198 0x18d70f818 0x18d70a550 0x10007ce20 0x1867185b8)
libc++abi.dylib: terminating with uncaught exception of type NSException横屏正常,勾选upside down也正常。
核心代码:
//AppController.mm
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
cocos2d::Application *app = cocos2d::Application::getInstance();
app->initGLContextAttrs();
cocos2d::GLViewImpl::convertAttrs();
/
/
window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
pixelFormat: (NSString*)cocos2d::GLViewImpl::_pixelFormat
depthFormat: cocos2d::GLViewImpl::_depthFormat
preserveBackbuffer: NO
sharegroup: nil
multiSampling: NO
numberOfSamples: 0 ];
[eaglView setMultipleTouchEnabled:YES];/ viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; viewController.wantsFullScreenLayout = YES; viewController.view = eaglView; / if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) { / [window addSubview: viewController.view]; } else { / [window setRootViewController:viewController]; } [window makeKeyAndVisible]; [[UIApplication sharedApplication] setStatusBarHidden: YES]; [[GameKitHelper sharedGameKitHelper] authenticateLocalPlayer]; / cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView(eaglView); cocos2d::Director::getInstance()->setOpenGLView(glview); app->run(); return YES;
}
GameKitHelper:
...
(void) authenticateLocalPlayer
{
if([self isGameCenterAvailable]){
GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];if (SYSTEM_VERSION_LESS_THAN(@"6.0")) { / [localPlayer authenticateWithCompletionHandler:^(NSError *error) { [self checkLocalPlayer]; }]; } else { / [localPlayer setAuthenticateHandler:(^(UIViewController* viewcontroller, NSError *error) {
})]; } }
}
RootViewController.mm
.../
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsPortrait( interfaceOrientation );
}
/
- (NSUInteger) supportedInterfaceOrientations{ifdef _IPHONE6_0
return UIInterfaceOrientationMaskPortraitUpsideDown;
endif
}
- (BOOL) shouldAutorotate {
return NO;
}
帖子: 1
参与者: 1