Gamecenter:com.apple.GameCenterUI.GameCenterDashboardExtension无效

时间:2016-07-13 21:35:25

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

关于此问题已经发布了很多问题,在Gamecenter VC上按完后会出现在控制台中。所以,我会把它重新引起注意,因为它仍在发生,而其他问题没有答案:

  

插件com.apple.GameCenterUI.GameCenterDashboardExtension无效

我的代码:

viewDidLoad中的身份验证:

GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
localPlayer.authenticateHandler = ^(UIViewController *viewController, NSError *error){
    if (viewController != nil)
    {
        [self presentViewController:viewController
                           animated:YES
                         completion:nil];
    }
};

IBAction中提交分数并打开排行榜:

GKLocalPlayer *localPlayer = [GKLocalPlayer localPlayer];
if (localPlayer.authenticated) {

    NSUInteger highscore = [self retrieveHighscore];

    GKScore *gkScore = [[GKScore alloc] initWithLeaderboardIdentifier:@"Leaderboard" player:localPlayer];
    gkScore.value = highscore;
    [GKScore reportScores:@[gkScore] withCompletionHandler:^(NSError * _Nullable error) {
    }];

    GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init];
    if (gameCenterController != nil) {
        gameCenterController.gameCenterDelegate = self;
        gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
        gameCenterController.leaderboardTimeScope = GKLeaderboardTimeScopeAllTime;
        gameCenterController.leaderboardIdentifier = @"Leaderboard";
        [self presentViewController: gameCenterController animated: YES completion:nil];
    }
}

任何解决方案?提前谢谢。

0 个答案:

没有答案