0
我是一个新的程序员,我有2个视图控制器,当我的游戏结束后,弹出一个“再次播放”按钮。返回主视图控制器?
而不是在第二个视图控制器上的计时器后重新启动游戏我希望该游戏再次返回到具有播放按钮的第一个视图控制器。我该怎么办?我有以下警报代码:
func subtractTime() {
seconds--
timerLabel.text = "Time: \(seconds)"
if(seconds == 0) {
timer.invalidate()
let alert = UIAlertController(title: "Time is up!",
message: "You scored \(count) points",
preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Play Again", style: UIAlertActionStyle.Default, handler: {
action in self.setupGame()
}))
presentViewController(alert, animated: true, completion:nil)
}
}