在我GameScene.swift文件,我想执行SEGUE回到我的菜单 - 视图 - 控制器,像这样:Segue公司在SKScene到UIViewController中
func returnToMainMenu(){
var vc: UIViewController = UIViewController()
vc = self.view!.window!.rootViewController!
vc.performSegueWithIdentifier("menu", sender: vc)
}
当一个节点被窃听此方法运行:
override func touchesEnded(touches: NSSet, withEvent event: UIEvent) {
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
if gameOn == false{
if restartBack.containsPoint(location){
self.restartGame()
}
else if menuBack.containsPoint(location){
self.returnToMainMenu()
}
else if justBegin == true{
self.restartGame()
}
}
}
}
其中menuBack
是回到菜单的按钮。我每次运行此代码,我抛出一个NSException:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<ProxyBlock.Menu: 0x165a3e90>) has no segue with identifier 'menu''
我检查了我赛格瑞的标识,它的确是“菜单”。
一个SEGUE用于转到从一个的viewController到另一个,而不是从一个场景到的viewController – ZeMoon 2014-11-21 06:13:21
你需要调用,而不是根本的viewController从现场的的viewController的SEGUE。 – ZeMoon 2014-11-21 07:14:28