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)
}
}