我想在我的应用中加入GameCenter排行榜,但我遇到了一个问题。
当我想要显示LeaderBoard时,我使用此代码:
//shows leaderboard screen
func showLeader() {
var vc = self.view?.window?.rootViewController
var gc = GKGameCenterViewController()
gc.gameCenterDelegate = self
vc?.presentViewController(gc, animated: true, completion: nil)
}
为此,我必须在我的班级中使用GKGameCenterControllerDelegate:
class FirstViewController: UIViewController, GKGameCenterControllerDelegate {
当我这样做时,我有一个错误:'键入FirstViewController'不符合协议' GKGameCenterControllerDelegate'。
任何解决方案?
答案 0 :(得分:1)
您需要包含以下方法:
func gameCenterViewControllerDidFinish(gcViewController: GKGameCenterViewController!)
{
// By tapping on Done, the Game Center window will be dismissed.
self.dismissViewControllerAnimated(true, completion: nil)
}