我正在尝试通过GameKit实现记分板,而我遇到的问题是我的查询只返回localPlayer的分数。我已经在itunes connect中设置了两个测试用户,并且他们两个都看到了这个问题,它只返回当前登录的任何玩家的最高分,并且根本不返回其他玩家的分数。我有一个表视图,其中包含两个数组,一个用于玩家分数,一个用于玩家名称。
- (void)loadGlobalHighScores
{
GKLeaderboard *leaderboard = [[GKLeaderboard alloc] init];
leaderboard.identifier = @"MyLeaderBoardIdentifier";
leaderboard.playerScope = GKLeaderboardPlayerScopeGlobal;
leaderboard.timeScope = GKLeaderboardTimeScopeAllTime;
leaderboard.range = NSMakeRange(1, 100);
[leaderboard loadScoresWithCompletionHandler:^(NSArray *scores, NSError *error) {
NSMutableArray *playerIDs = [NSMutableArray array];
NSMutableArray *playerScores = [NSMutableArray array];
for (GKScore *score in scores)
{
[playerIDs addObject:score.playerID];
[playerScores addObject:[NSNumber numberWithLongLong:score.value]];
}
self.playerScores = playerScores;
[GKPlayer loadPlayersForIdentifiers:playerIDs withCompletionHandler:^(NSArray *players, NSError *error) {
NSMutableArray *playerNames = [NSMutableArray array];
for (GKPlayer *player in players)
{
[playerNames addObject:player.displayName];
}
self.playerNames = playerNames;
[self.highScoresTable reloadData];
}];
}];
}
据我所知,我做的一切都是正确的,我不确定这是测试用户帐户的问题还是什么。