使用SpriteKit的GameCenter排行榜的未定义行为

时间:2014-05-11 23:59:22

标签: sprite-kit game-center game-center-leaderboard

我尝试通过此代码块显示排行榜

if ([GKLocalPlayer localPlayer].isAuthenticated) {
    GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init];
    if (gameCenterController != nil)
    {
        gameCenterController.gameCenterDelegate = self;
        gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
        UIViewController *vc = self.view.window.rootViewController;
        [vc presentViewController: gameCenterController animated:YES completion:Nil];
    }
    }else{
            UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"You must enable Game Center"
                                                              message:@"Sign in through the Game Center app to enable all features"
                                                             delegate:nil
                                                    cancelButtonTitle:@"OK"
                                                    otherButtonTitles:nil];
            [message show];
    }

如果我启用了所有异常断点,那么在呈现排行榜的那一刻它就会崩溃。当我删除这个断点时,一切正常。我和测试用户一起登录了Game Center。这是一个小问题还是什么?

1 个答案:

答案 0 :(得分:0)

我通过编辑从所有到Objective-C异常的异常断点来解决它。 Tnx @ LearnCocos2D的答案