我已經生成了一個UIAlert,我想鏈接這個來打開一個新的viewController。我爲每個不同的viewcontrollers添加了新文件,並且已經鏈接了這個類。UIAlertController去新的ViewController
的代碼,我是...
@IBAction func CorrectButton(_ sender: UIButton) {
let refreshAlert = UIAlertController(title: "Correct Answer", message: "Congratulations", preferredStyle: UIAlertControllerStyle.alert)
let vc = ThirdViewController()
refreshAlert.addAction(UIAlertAction(title: "Ok", style: .default, handler: { (action: UIAlertAction!) in self.present(vc, animated: true, completion: nil)
}))
present(refreshAlert, animated: true, completion: nil)
}
基本上,當用戶點擊了正確答案,當用戶點擊「OK」我希望有一個新視圖控制器以彈出一個警告會彈出,然後應用程序的下一部分。目前發生的所有事情是當我點擊警報消息中的「確定」時,屏幕會變黑。
任何幫助將不勝感激..