ios - 选择游戏中心部分目的地

标签 ios swift uiviewcontroller game-center

我正在使用此功能打开 Game Center。它默认打开成就,然后我必须单击下一部分才能查看排行榜。是否可以直接打开排行榜?

func showLeaderBoard() {

    let ViewController = self.view.window?.rootViewController
    let gcvc = GKGameCenterViewController()

    gcvc.gameCenterDelegate = self

    ViewController?.present(gcvc, animated: true, completion: nil)
}

在下图中,您可以看到它默认打开成就。我正在寻找一种方法让它直接在排行榜中打开。

enter image description here

最佳答案

您应该分配 viewState GKGameCenterViewController的属性(property).试试这个

func showLeaderBoard() {

    let ViewController = self.view.window?.rootViewController
    let gcvc = GKGameCenterViewController()
    gcvc.gameCenterDelegate = self
    gcvc.viewState = GKGameCenterViewControllerState.Leaderboards

    ViewController?.present(gcvc, animated: true, completion: nil)
 }

关于ios - 选择游戏中心部分目的地,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43500011/

相关文章:

ios - 使用 Storyboard实例化的 Controller 的重新分配

ios - UIView 应该观察通知吗?

ios - 无法创建 3 列 UICollectionView

ios - MVC : Where do I place custom UICollectionCell

ios - ITMS-90809 : Deprecated API Usage - existing app that use UIWebView are no longer accepted

ios - 如何在 View Controller 中多次加载相同的 View

string - “字符串”无法转换为 '[(String)]'

iphone - iOS:通用应用程序不会旋转,从不调用 willRotateToInterfaceOrientation

android - 为什么在添加依赖项后从导入行重定向时 http.dart 文件显示为空,而且 http.get(url) 方法未完成

ios - 如何获取NSString中最后一个字母之前的字符?