Reputation: 27
I want to include a GameCenter Leaderboard in my app but I have one problem.
When I want to show LeaderBoard, I use this code :
//shows leaderboard screen
func showLeader() {
var vc = self.view?.window?.rootViewController
var gc = GKGameCenterViewController()
gc.gameCenterDelegate = self
vc?.presentViewController(gc, animated: true, completion: nil)
}
For that, I must had GKGameCenterControllerDelegate in my class like that :
class FirstViewController: UIViewController, GKGameCenterControllerDelegate {
When I do that, I have an error : 'type FirstViewController' does not to conform to protocol 'GKGameCenterControllerDelegate'.
Any solution ?
Upvotes: 0
Views: 111
Reputation: 1708
You need to include the following method:
func gameCenterViewControllerDidFinish(gcViewController: GKGameCenterViewController!)
{
// By tapping on Done, the Game Center window will be dismissed.
self.dismissViewControllerAnimated(true, completion: nil)
}
More info here: https://developer.apple.com/library/mac/documentation/GameKit/Reference/GKGameCenterViewControllerDelegate_Ref/
Upvotes: 1