Search code examples
iosswiftuiviewcontrollerskscene

Present a UIViewController from a SKScene


I have a GameViewController that presents a SKScene, and I want to present a new UIViewController from that SKScene, I have been searching for a long time, and I just can't find an answer.


Solution

  • If I understand your problem correctly, you want to show/present a UIViewController from an SKScene?

    If yes, you would need to use a Segue. I used this in my SKScene in my game to get back to the menu, which is

    var vc: UIViewController = UIViewController()
    vc = self.view!.window!.rootViewController!
    self.viewController?.performSegueWithIdentifier("backToMenu", sender: vc)
    

    Am I off topic? If yes please tell me and I will try to change my answer (instead of voting down), as I am unsure of what you want to do exactly.