【发布时间】:2017-03-22 19:54:42
【问题描述】:
我有一个警报控制器,想在按下 OK 后关闭视图控制器,但不知道怎么做。 self.dismiss(animated: true) 只关闭警报控制器本身。这是我的代码。
let alertController: UIAlertController = UIAlertController(title: "Password updatd", message: "Your password has been changed successfully", preferredStyle: .alert)
let okAction: UIAlertAction = UIAlertAction(title: "OK", style: .default) { action -> Void in }
alertController.addAction(okAction)
self.present(alertController, animated: true, completion: nil)
我试过这个,它只删除了当前的视图控制器,但没有回到根视图控制器。
let okAction: UIAlertAction = UIAlertAction(title: "OK", style: .default) { action -> Void in
self.navigationController?.popToRootViewController(animated: true)}
这给了我一个警告expression of type UIViewController is unused。
【问题讨论】: