无法解雇游戏中心排行榜

时间:2015-01-15 23:25:38

标签: objective-c iphone game-center game-center-leaderboard

我有一个应用程序,我正在使用GameCenter排行榜。 但我不能忽视排行榜:

这是我的代码:

-(void)showLeaderboard {


GKGameCenterViewController *leaderboardController = [[GKGameCenterViewController alloc] init];

if (leaderboardController != NULL)
{
    leaderboardController.leaderboardIdentifier = @"Leaderboard";
    leaderboardController.viewState = GKGameCenterViewControllerStateLeaderboards;
    leaderboardController.gameCenterDelegate = self;
    UIViewController *vc = self.view.window.rootViewController;
    [vc presentViewController: leaderboardController animated: YES completion:nil];
}
}

- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)viewController
{
    NSLog(@"Close");
    UIViewController *vc = self.view.window.rootViewController;
    [vc dismissViewControllerAnimated:YES completion:nil];
}

我不知道该怎么做,: -

1 个答案:

答案 0 :(得分:1)

尝试解雇代码中的viewController

像这样更改你的代码

-(void)showLeaderBoard
{
    if (leaderboardController != NULL)
    {
        leaderboardController.leaderboardIdentifier = @"Leaderboard";
        leaderboardController.viewState = GKGameCenterViewControllerStateLeaderboards;
        leaderboardController.gameCenterDelegate = self;
        [self presentViewController: leaderboardController animated: YES completion:nil];
    }
}
- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)viewController
{
    [viewController dismissViewControllerAnimated:YES completion:nil];
}