4

Usaly when you present a viewController from another viewController you do:

let vc : UIViewController = storyboard.instantiateViewControllerWithIdentifier("viewController") as UIViewController;
self.presentViewController(vc, animated: true, completion: nil);

I want to present a viewController from a SKScene. I haven't found any way of doing that. This question might be a duplicate, but i have just found answers in objective C that doesn't make sense to me

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
tim_yng
  • 2,591
  • 4
  • 18
  • 20
  • 1
    pretty sure there are also swift-specific questions (some even may have answers) because "how to access view controller from scene", "how to present view controller from scene" and similar are very frequently asked questions – CodeSmile Sep 26 '14 at 19:30

1 Answers1

9

Try the following in your scene class:

var currentViewController:UIViewController=UIApplication.sharedApplication().keyWindow.rootViewController!

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

I hope it helps.

Endre Olah
  • 875
  • 2
  • 9
  • 25