“GKScore必须指定排行榜。” [英] "A GKScore must specify a leaderboard."
本文介绍了“GKScore必须指定排行榜。”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尝试将Game Center集成到iOS 7应用程序时是否有人遇到此错误?
Has anyone come across this error when trying to integrate Game Center into an iOS 7 App?
GKScore必须指定排行榜。
A GKScore must specify a leaderboard.
以下是失败的代码:
if(points > 0)
{
//Fails on the next line
[self.gameCenterManager reportScore:points forCategory:self.currentLeaderBoard];
}
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
if (leaderboardController != NULL) {
leaderboardController.category = self.currentLeaderBoard;
leaderboardController.timeScope = GKLeaderboardTimeScopeWeek;
leaderboardController.leaderboardDelegate = self;
[self presentViewController:leaderboardController animated:YES completion:nil];
}
UPDATE 我尝试了另一种方法仍然可以获得同样的错误。
UPDATE I have tried another method and still get the same error.
其他方法:
GKScore *scoreReporter = [[GKScore alloc] initWithCategory:self.currentLeaderBoard];
scoreReporter.value = points;
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
if (error != nil)
{
[self showAlert:@"Game Center Error" theMessage:@"There was a problem uploading your score to Game Center, if this problem persists, please contact JApp Design." alertTag:0];
}
}];
任何想法?
推荐答案
随着iOS 7.0的推出,这种报告分数的方法似乎已被弃用
This method of reporting scores appears to be deprecated with the introduction of iOS 7.0
以下是解决问题的代码:
Here is the code that will fix the problem:
GKScore *reportScore = [[GKScore alloc] initWithLeaderboardIdentifier:@"leaderBoardI"];
reportScore.value = totalPoints;
NSArray *scores = @[reportScore, nil];
[GKScore reportScores:scores withCompletionHandler:nil];
这篇关于“GKScore必须指定排行榜。”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文