gpt4 book ai didi

ios - "A GKScore must specify a leaderboard."

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:35:52 25 4
gpt4 key购买 nike

有人在尝试将 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com