在我的项目中,我使用 rootViewController?.dismiss 将一些视图控制器解散回主 VC。
在完成处理程序中,一旦 UIAlertController 再次可见,我想在主视图控制器上显示它。
我的问题是 UIAlertController 永远不会出现。我的预感是因为我在 launchFrom 参数中使用了 self 。我是否需要获得对主要 VC 的引用,并在那里展示它?
关闭 VC 并尝试显示警报:
self.view.window!.rootViewController?.dismiss(animated: false, completion: {
Constants.presentThankYou(launchFrom: self)
})
presentThankYou 方法
static func presentThankYou(launchFrom: UIViewController) {
let alertController = UIAlertController(title: "Thank You!", message: "You did it!", preferredStyle: UIAlertControllerStyle.alert)
let okAction = UIAlertAction(title: "Close", style: UIAlertActionStyle.default) { (result : UIAlertAction) -> Void in
print("Done")
}
alertController.addAction(okAction)
launchFrom.present(alertController, animated: true, completion: nil)
}
在我的所有 VC 都被解雇后,我如何提交警报控制器?