【发布时间】:2020-10-02 07:15:13
【问题描述】:
我使用的是最新的Xcode 和Swift 版本。
我正在展示一个特定的View Controller,如下所示:
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let contactViewController = storyboard.instantiateViewController(identifier: "contactViewController")
show(contactViewController, sender: self)
我将像这样解雇这个View Controller:
self.presentingViewController?.dismiss(animated: true, completion: nil)
我想在关闭View Controller 后立即显示UIAlertController。
这个:
self.presentingViewController?.dismiss(animated: true, completion: nil)
let alertMessage = UIAlertController(title: "Your message was sent", message: "", preferredStyle: .alert)
let alertButton = UIAlertAction(title: "Okay", style: UIAlertAction.Style.default)
alertMessage.addAction(alertButton)
self.present(alertMessage, animated: true, completion: nil)
...当然不起作用,因为我不能在已解散的View Controller 上显示UIAlertController。
在View Controller 被关闭后,呈现此UIAlertController 的最佳方式是什么?
【问题讨论】:
标签: ios swift xcode uiviewcontroller uialertcontroller