【问题标题】:iOS 6 Game Center Crash on Authentication in landscape mode cocos2diOS 6 Game Center 在横向模式 cocos2d 中的身份验证崩溃
【发布时间】:2013-07-23 05:20:42
【问题描述】:

我用 cocos2d 开发了一个游戏,所有的游戏画面都是横屏模式。我正在尝试实现游戏中心,但在身份验证时出现崩溃。我没有找到类似问题的答案。请提出正确的方法...

崩溃问题:-'UIApplicationInvalidInterfaceOrientation',原因:'支持的方向与应用程序没有共同的方向,并且 shouldAutorotate 正在返回 YES'

我尝试了以下解决方案,但它也干扰了游戏方向,游戏也以纵向模式开始工作,我不想要:-

  • (NSUInteger)应用程序:(UIApplication*)应用程序

    supportedInterfaceOrientationsForWindow: (UIWindow*)window { 返回 UIInterfaceOrientationMaskAllButUpsideDown; }

【问题讨论】:

    标签: crash cocos2d-iphone orientation game-center landscape


    【解决方案1】:

    确保您在 Xcode 摘要页面中选择了横向。

    在你的视图控制器中添加这些代码

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

    在 AppDelegate 中更新这个函数:

    - (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
    {
        return UIInterfaceOrientationMaskLandscape;
    }
    

    【讨论】:

    • 首先游戏中没有ViewController,是通过导航控制器,其次游戏中心认证崩溃,因为所有游戏的横向和蒙版也设置正确,请尝试在ios中实现仅支持 6 个横向 - navController_ = [[UINavigationController alloc] initWithRootViewController:director_]; navController_.navigationBarHidden = YES; // 将 Navigation Controller 设置为根视图控制器 // [window_addSubview:navController_.view]; // 产生闪烁。 [window_setRootViewController:navController_];
    • 好的,它的 cocos2d 2.0,在supportedInterfaceOrientationsForWindow 中更改类型景观,并且不会在设备中崩溃...仅在模拟器中...
    • 能否请您显示完整的功能代码,视图控制器代码呢?
    • 在 cocos2d 1.0 中仅使用 rootviewcontroler...在 cocos2d 2.0 中您可以在 AppDelegate 中找到...已经添加。现在在设备中崩溃修复了吗?
    • 如果我能给这个答案投票一百万次,我会的。天哪,我花了这么多时间研究这个问题,并且有很多答案说“如果你想要游戏中心,你只需要从 iOS 6 开始启用纵向方向。”很明显,你没有! (这很好,因为为其他仅限风景的游戏启用肖像会产生许多其他问题。)您的回答 100% 为我解决了这个问题。谢谢!
    【解决方案2】:

    解决方案很短,我花了很多时间才找到它:

    AppDelegate方法didFinishLaunchingWithOptions中放这一行:

    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
    

    显然在调用登录游戏中心方法之前,我把它放在创建UIWindows之前

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-09
      • 1970-01-01
      • 2012-03-24
      相关资源
      最近更新 更多