问题
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