我一直坚持从SKScene过渡到我已经添加到Main.storyboard的ViewController。我知道有很多相同的问题,但对我来说没有任何作用。 无论如何,如果我得到答案,我将不胜感激。
我要转换的代码:
func presentNextVC() {
let vc = UIViewController(nibName: "NextVC", bundle: nil) as UIViewController
if let responder = self.view?.nextResponder() {
let vc = responder as UIViewController
vc.presentViewController(NextVC(), animated:true, completion:nil)
}
此函数将由TouchedNode事件调用。当触摸节点时,我认为它移动到NextVC,但我只得到一个黑屏。
//编辑:解决方案:
func presentNextVC() {
let vc = UIStoryboard(name: "Main", bundle:nil).instantiateViewControllerWithIdentifier("NextVc") as UIViewController
let currentViewController = (UIApplication.sharedApplication().delegate as AppDelegate)
currentViewController.window?.rootViewController?.presentViewController(vc, animated: true, completion: nil)
}