【发布时间】:2017-02-26 23:08:57
【问题描述】:
我已经生成了一个 UIAlert,我想链接它来打开一个新的 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)
}
基本上,当用户单击正确答案时,会弹出警报,然后当用户单击“确定”时,我希望在应用程序的下一部分弹出一个新的视图控制器。当前发生的所有事情是当我单击警报消息中的“确定”时屏幕变黑了?
任何帮助将不胜感激..
【问题讨论】:
标签: swift uiviewcontroller uialertcontroller