game-center - 如何在tvOS中打开GameCenter

标签 game-center tvos apple-tv game-center-leaderboard

如何在tvOS中打开游戏中心排行榜?我已经在我的iPhone游戏中使用了此代码,但tvOS上不提供“leaderboardIdentifier”。

我计划在AppleTV上使用相同的排行榜(它将是同一游戏)。

非常感谢您的帮助,
斯特凡

    @IBAction func handleGameCenter(sender: UIButton) {
        let gcViewController = GKGameCenterViewController()
        gcViewController.viewState = GKGameCenterViewControllerState.Leaderboards
        gcViewController.leaderboardIdentifier = gamePrefix + "Leaderboard"
        gcViewController.gameCenterDelegate = self

        // Show leaderboard
        self.presentViewController(gcViewController, animated: true, completion: nil)
    }

    func gameCenterViewControllerDidFinish(gameCenterViewController: GKGameCenterViewController) {
        gameCenterViewController.dismissViewControllerAnimated(true, completion: nil)
    }

最佳答案

我也遇到了“无可用数据”屏幕的问题,但终于解决了。这对我来说可以在tvOS上打开gamecenter排行榜:

  • 打开Assets.xcassets(您在其中设置应用程序图标/启动屏幕的同一文件)
  • 右键单击带有appicon/launchsreen的面板,然后选择Game Center-> New Apple TV排行榜
  • 为新的排行榜添加图形
  • 在右侧面板的 Assets 文件中选择排行榜时,
  • 找到“标识符”字段,然后在其中放置排行榜的标识符
  • 使用以下代码打开排行榜:
    GKGameCenterViewController *gcViewController = [[GKGameCenterViewController alloc] init];
    gcViewController.gameCenterDelegate = self;
    [self presentViewController:gcViewController animated:YES completion:nil];
    
  • 关于game-center - 如何在tvOS中打开GameCenter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32770956/

    相关文章:

    ios - GKPlayer - 存储自定义数据

    ios - 如何在外部触摸屏显示器上运行 Apple tvOS 或 IOS 应用程序

    swift - 当 UIButton 获得焦点时,Siri Remote 的菜单按钮不会退出应用程序

    objective-c - tvOS:当按钮处于水平顺序时,将第一个按钮作为首选焦点 View

    swift - Gamekit 多人游戏和不同的屏幕尺寸

    iphone - GameCenter 功能崩溃应用程序 - 谁能帮忙解决?

    ios6 - iOS 6 Game Center authenticationHandler 取消后无法登录

    swift - TVOS : Adjust the position of searchbar in UISearchViewController

    swift - 如何使用 Apple TV 上的焦点引擎使 UIView 可聚焦

    uiviewcontroller - tvOS 中的presentControllerWithName