如何从SKScene呈现UIViewController

时间:2014-09-26 18:16:24

标签: swift uiviewcontroller sprite-kit skscene

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

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

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

1 个答案:

答案 0 :(得分:8)

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

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

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

我希望它有所帮助。