在我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