ios - "A GKScore must specify a leaderboard."
<p><p>有没有人在尝试将 Game Center 集成到 iOS 7 应用程序时遇到此错误?</p>
<blockquote>
<p>A GKScore must specify a leaderboard.</p>
</blockquote>
<p>这是失败的代码:</p>
<pre><code>if(points > 0)
{
//Fails on the next line
;
}
GKLeaderboardViewController *leaderboardController = [ init];
if (leaderboardController != NULL) {
leaderboardController.category = self.currentLeaderBoard;
leaderboardController.timeScope = GKLeaderboardTimeScopeWeek;
leaderboardController.leaderboardDelegate = self;
;
}
</code></pre>
<p><strong>更新</strong>我尝试了另一种方法,但仍然遇到同样的错误。</p>
<p>其他方法:</p>
<pre><code>GKScore *scoreReporter = [ initWithCategory:self.currentLeaderBoard];
scoreReporter.value = points;
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
if (error != nil)
{
;
}
}];
</code></pre>
<p>有什么想法吗?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我和你有同样的问题,但我解决了我的问题..</p>
<p>这是我的原始代码。</p>
<pre><code>GKScore *scoreReporter = [ initWithLeaderboardIdentifier: identifier];
scoreReporter.value = score;
scoreReporter.context = 0;
scoreReporter.shouldSetDefaultLeaderboard = YES;
NSArray *scores = @;
[GKScore reportScores:scores withCompletionHandler:^(NSError *error) {
//Do something interesting here.
;
}];
</code></pre>
<p>从这里,我删除了这条线。 <code>scoreReporter.shouldSetDefaultLeaderboard = YES</code>
所以它工作得很好。 </p></p>
<p style="font-size: 20px;">关于ios - "A GKScore must specify a leaderboard.",我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/22273320/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/22273320/
</a>
</p>
页:
[1]