无法加载iOS 7上的排行榜得分 [英] Cannot load top leaderboard score on iOS 7

查看:124
本文介绍了无法加载iOS 7上的排行榜得分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个功能可以从我的iOS游戏的排行榜中加载最高分,它在iOS 6中有效但在iOS 7中不再有效。我使用的功能如下:

I had a function to load the top score from the leaderboard for my iOS game, and it worked in iOS 6 but it no longer works in iOS 7. The function I used is as follows:

- (void) retrieveGlobalHighScore {
if(userAuthenticated == true) {
    //NSLog(@"Attempting to retrieve global high score...");
    GKLeaderboard *leaderboardRequest = [[GKLeaderboard alloc] init];
    if (leaderboardRequest != nil) {
        leaderboardRequest.playerScope = GKLeaderboardPlayerScopeGlobal;
        leaderboardRequest.timeScope = GKLeaderboardTimeScopeAllTime;
        leaderboardRequest.range = NSMakeRange(1,1);
        [leaderboardRequest loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) {
            if (error != nil) {
                // handle the error. if (scores != nil)
                NSLog(@"ERROR: Issue loading global high score.");
                NSLog(@"Unresolved error %@", error);
            }
            if (scores != nil){
                // process the score information.
                globalHighScoreReturn = ((GKScore*)[scores objectAtIndex:0]).value;
            }
        }];
    }
} else {
    //NSLog(@"User is not authenticated. Global high score not loaded.");
  }
}

我现在得到以下错误,无法弄清楚如何解决它:

I now get the following error and cannot figure out how to fix it:

Error Domain=GKErrorDomain Code=17 
"The requested operations could not be completed because one or more parameters are invalid." 

UserInfo=0xf539250 {GKServerStatusCode=5053, NSUnderlyingError=0xf538670 "The operation couldn’t be completed. 

status = 5053, asking for legacy aggregate leaderboard on a game with no legacy aggregate leaderboard", NSLocalizedDescription=The requested operations could not be completed because one or more parameters are invalid.}

任何帮助将不胜感激!

推荐答案

我发现了这个问题。在iOS 6中,不需要设置leaderboardRequest.category,并且自动选择了默认排行榜(我只使用1)。在iOS 7中,必须指定类别。指定标识符也可以,但我支持iOS 6和7。

I found the issue. In iOS 6, setting leaderboardRequest.category was not needed and the default leaderboard (I am only using 1) was automatically selected. In iOS 7, the category had to be specified. Specifying the identifier worked as well, however I am supporting both iOS 6 and 7.

这篇关于无法加载iOS 7上的排行榜得分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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