2

我有一个应用程序,我正在使用 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];
}

我不知道该怎么做, :-

4

1 回答 1

2

尝试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];
}
于 2015-01-16T03:28:42.793 回答