Game Center leaderboard shows one result

牧云@^-^@ 提交于 2019-12-10 11:36:09

问题


I've sent scores to the leaderboard with different test accounts but when I try to see the leaderboard I can only see the score from the account that I'm logged in. I used this code to send the scores :

    - (void)reportScore:(int64_t)score forLeaderboardID:(NSString*)identifier
{
    GKScore *scoreReporter = [[GKScore alloc] initWithLeaderboardIdentifier: @"GHS"];
    scoreReporter.value = score;
    scoreReporter.context = 0;

    [GKScore reportScores:@[scoreReporter] withCompletionHandler:^(NSError *error) {
        if (error == nil) {
            NSLog(@"Score reported successfully!");
        } else {
            NSLog(@"Unable to report score!");
        }
    }];
}

This is the code I'm using to show the leaderboard:

- (void)showLeaderboardOnViewController:(UIViewController*)viewController
{
    GKGameCenterViewController *gameCenterController = [[GKGameCenterViewController alloc] init];
    if (gameCenterController != nil) {
        gameCenterController.gameCenterDelegate = self;
        gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
        gameCenterController.leaderboardIdentifier = _leaderboardIdentifier;

        [viewController presentViewController: gameCenterController animated: YES completion:nil];
    }
}

Maybe it's because it is sandboxed and stuff? is this normal maybe? Thanks


回答1:


I've had this issue before and after much searching it seems to be an error with sandbox accounts. I split my table into highest of all time, highest today and highest friend and in each case other higher scores from my other sandbox accounts were ignored. When I added another one of my accounts as a friend, they started sharing scores just fine.

I used code more or less identical to your own and submitted to the App Store where it was accepted, now it works fine with live accounts.



来源:https://stackoverflow.com/questions/24397963/game-center-leaderboard-shows-one-result

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!