首页 文章

iOS 6游戏中心在横向模式cocos2d中进行身份验证时崩溃

提问于
浏览
0

我用cocos2d开发了一款游戏,所有游戏画面都处于横向模式 . 我正在尝试实现游戏中心,但在身份验证方面遇到了崩溃 . 我没有找到类似问题的答案 . 请建议正确的方法......

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

我尝试了下面的解决方案,但它也打扰了游戏方向,游戏开始工作在肖像模式也,我不想要: -

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

supportedInterfaceOrientationsForWindow:(UIWindow *)window {return UIInterfaceOrientationMaskAllButUpsideDown; }

2 回答

  • 2

    对此的解决方案很简短,我在找到它之前花了很多时间:

    在方法 didFinishLaunchingWithOptionsAppDelegate 中放置此行:

    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
    

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

  • 0

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

    enter image description here

    还要在viewcontroller中添加这些代码

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

    在AppDelegate中更新此函数:

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

相关问题