3

I am trying to add Game Center Leaderboards and achievements into my game but I can not find any tutorials for SpriteKit in Swift. All of the tutorials have

    self.presentViewController(viewController, animated: true, completion: nil)

but in Sprite Kit that doesn't work

Loanb222
  • 841
  • 1
  • 11
  • 29

1 Answers1

4

You can just call it like that, if you are in a UIViewController already. But if you want to show an UIViewController from your SKScene you should access the rootViewController and present the controller from there:

self.view?.window?.rootViewController?.presentViewController(yourViewController, animated: true, completion: nil)
Christian
  • 22,585
  • 9
  • 80
  • 106