有没有人在尝试将 Game Center 集成到 iOS 7 应用程序时遇到此错误?
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];
}
更新我尝试了另一种方法,但仍然遇到同样的错误。
其他方法:
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];
}
}];
有什么想法吗?
我和你有同样的问题,但我解决了我的问题..
这是我的原始代码。
GKScore *scoreReporter = [[GKScore alloc] initWithLeaderboardIdentifier: identifier];
scoreReporter.value = score;
scoreReporter.context = 0;
scoreReporter.shouldSetDefaultLeaderboard = YES;
NSArray *scores = @[scoreReporter];
[GKScore reportScores:scores withCompletionHandler:^(NSError *error) {
//Do something interesting here.
[self callDelegateOnMainThread: @selector(scoreReported withArg: NULL error: error];
}];
从这里,我删除了这条线。 scoreReporter.shouldSetDefaultLeaderboard = YES
所以它工作得很好。
关于ios - "A GKScore must specify a leaderboard.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22273320/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |