【问题标题】:Display Specific Leaderboard in Game Center?在游戏中心显示特定的排行榜?
【发布时间】:2016-05-06 19:01:45
【问题描述】:

在我的 iOS9 项目中,我共有 8 个与 Game Center 相关的排行榜。我可以加载所有排行榜的列表(这对于我的应用程序的另一部分来说非常棒);但是,我也希望能够加载一个特定的排行榜。这是我正在使用的代码:

 @IBAction func showLeaderboard() {
    if savedSettings["difficulty"] == 0 {
        print("Easy")
        if savedSettings["gameLanguage"] == 0 {
            leaderboardID = "Colorific_English_High_Scores"
            print("english")
        } else if savedSettings["gameLanguage"] == 1 {
            leaderboardID = "Colorific_Spanish_High_Scores"
        } else {
            leaderboardID = "Colorific_French_High_Scores"
        }
    } else {
        if savedSettings["gameLanguage"] == 0 {
            leaderboardID = "Colorific_English_High_Scores_Hard"
        } else if savedSettings["gameLanguage"] == 1 {
            leaderboardID = "Colorific_Spanish_High_Scores_Hard"
        } else {
            leaderboardID = "Colorific_French_High_Scores_Hard"
        }
    }
    let gcVC: GKGameCenterViewController = GKGameCenterViewController()
    gcVC.leaderboardIdentifier = leaderboardID
    gcVC.gameCenterDelegate = self

    gcVC.viewState = GKGameCenterViewControllerState.Leaderboards

    self.presentViewController(gcVC, animated: true, completion: nil)
}

很遗憾,更新 leaderboardIdentifier 似乎没有任何效果。所有排行榜的列表似乎总是出现。事实上......即使将 viewState 更改为 GKGameCenterViewControllerState.Achievements 似乎也没有效果!它总是进入排行榜列表:(

提前感谢您的所有帮助! :)

【问题讨论】:

    标签: ios9 game-center leaderboard


    【解决方案1】:

    我知道这是很久以前发布的,但我在我的项目中遇到了同样的问题。

    你的代码没有问题,问题是iOS9的一个bug,苹果官方论坛上有一个帖子与其他人的抱怨:https://forums.developer.apple.com/thread/15997。 他们在显示特定排行榜时都有相同的问题,但是 Apple 没有官方回答。

    我在装有 iOS8 的设备上尝试了我的游戏,显示特定排行榜没有问题。所以现在,没有什么可做的,直到苹果解决这个问题(已经快一年了)。我还建议使用 Apple 错误报告器,以便他们注意到问题。

    iOS10 更新:

    iOS 10 显示特定排行榜没有问题。看起来它仍然是iOS9的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多