我有以下代码报告得分并显示排行榜。一切似乎都没问题但是当我发送新的更新分数时,除非我点击挑战标签或所有时间,否则它不会在排行榜上显示分数。基本上,它需要我点击排行榜内的其他内容,以便排行榜可以刷新并显示最新的分数。
func reportLeaderboardIdentifier(identifier: String, score: Int) {
let scoreObject = GKScore(leaderboardIdentifier: identifier)
scoreObject.value = Int64(score)
GKScore.reportScores([scoreObject]) { (error) -> Void in
if error != nil {
println("Error in reporting leaderboard scores: \(error)")
}
}
}
func displayLeaderboard () {
var gameCenterController: GKGameCenterViewController = GKGameCenterViewController()
gameCenterController.viewState = GKGameCenterViewControllerState.Leaderboards
gameCenterController.gameCenterDelegate = self
self.vc.presentViewController(gameCenterController, animated: true , completion:nil)
}
func gameCenterViewControllerDidFinish(gameCenterViewController: GKGameCenterViewController!) {
gameCenterViewController.dismissViewControllerAnimated(true, completion: nil)
}