我的场景,在我的项目中,我维护了三个 ViewController
(Main、VC1 和 VC2)
。在主要的 ViewController
中,我正在维护 UIButton
,单击此按钮可显示 Model View Controller 的 VC1
。同样,VC1
我正在维护 UIButton
,点击操作将模型呈现给 VC2
。 VC2
呈现后,我需要关闭 VC1。
// presenting ViewController
var presentingViewController: UIViewController! = self.presentingViewController
self.dismissViewControllerAnimated(false) {
// go back to MainMenuView as the eyes of the user
presentingViewController.dismissViewControllerAnimated(false, completion: nil)
}
最佳答案
在 VC2
的关闭按钮操作中试试这个
var vc = self.navigationController?.presentingViewController
while vc?.presentingViewController != nil {
vc = vc?.presentingViewController
}
vc?.dismiss(animated: true, completion: nil)
关于ios - 如何在使用 Swift 呈现新的 Viewcontroller 后关闭以前的 Viewcontroller?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56142973/