如何从SKScene呈现UIViewController

tim*_*yng 4 uiviewcontroller sprite-kit skscene swift

当你从另一个viewController呈现一个viewController时,你会这样做:

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

我想从SKScene呈现一个viewController.我没有找到任何办法.这个问题可能是重复的,但我刚刚在客观C中找到了对我没有意义的答案

End*_*lah 8

在场景类中尝试以下操作:

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

currentViewController.presentViewController(viewController, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

我希望它有所帮助.