Game Center排行榜显示一项结果 [英] Game Center leaderboard shows one result

查看:219
本文介绍了Game Center排行榜显示一项结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用不同的测试帐户将分数发送到了排行榜,但是当我尝试查看排行榜时,我只能从我登录的帐户中看到分数. 我使用此代码发送分数:

    - (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!");
        }
    }];
}

这是我用来显示排行榜的代码:

- (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];
    }
}

也许是因为它是沙盒之类的东西?这可能正常吗? 谢谢

解决方案

在进行大量搜索之前和之后,我都遇到了这个问题,这似乎是沙箱帐户的错误.我将表分成了有史以来最高的记录,今天的最高记录和最高的朋友,在每种情况下,我其他沙箱帐户中的其他较高分数都被忽略了.当我将另一个帐户添加为朋友时,他们开始共享分数就很好了.

我使用的代码与您使用的代码大致相同,并提交给了接受该代码的App Store,现在它可以与真实帐户正常工作了.

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

解决方案

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.

这篇关于Game Center排行榜显示一项结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆