Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to present UIViewController from SKScene

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

like image 403
tim_yng Avatar asked Jan 09 '23 17:01

tim_yng


1 Answers

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.

like image 71
Endre Olah Avatar answered Jan 16 '23 21:01

Endre Olah