【发布时间】:2020-11-10 05:46:55
【问题描述】:
我的故事板看起来像这样:-
Main View Controller -> Game View Controller -> Game Result View Controller
我执行了从 Main V.C 到 Game V.C 的模态转场。现在,当我从 Game V.C. 执行模态转场时。游戏结果 V.C.,游戏 V.C.没有关闭,因为游戏 V.C.检测是否开始触摸,当它检测到 Game V.C. 之外的触摸时会崩溃。在对 Game Result V.C. 执行模态转场之后我没有使用导航视图控制器。任何人都可以帮助我在对 Game Result V.C. 执行模态 segue 后如何关闭 Game V.C.?感谢您的帮助!谢谢:)
**Game V.C.**
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
// First touch to start the game
if gameState == .ready {
startGame()
}
if let touchLocation = event?.allTouches?.first?.location(in: self.view) {
// Move the player to the new position
movePlayer(to: touchLocation)
// Move all enemies to the new position to trace the player
moveEnemies(to: touchLocation)
}
}
func gameOver() {
stopGame()
performSegue(withIdentifier: "2to3segue", sender: self)
}
【问题讨论】: