在我的GameScene.swift文件中,我正在尝试将segue执行回我的菜单视图控制器,如下所示:
func returnToMainMenu(){
var vc: UIViewController = UIViewController()
vc = self.view!.window!.rootViewController!
vc.performSegueWithIdentifier("menu", sender: vc)
}
Run Code Online (Sandbox Code Playgroud)
点击节点时会运行此方法:
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()
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
哪里menuBack是按钮返回菜单.每次运行此代码时,都会抛出NSException:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<ProxyBlock.Menu: 0x165a3e90>) has no segue with identifier 'menu''
Run Code Online (Sandbox Code Playgroud)
我检查了我的segue的标识符,它确实是"菜单".