【发布时间】:2017-01-07 15:41:01
【问题描述】:
我有一个视图控制器“A”,它以模态方式呈现另一个视图控制器 B。
在故事板中它看起来像这样:
UIViewController "A" -> UINavigationViewController "B" -> rootViewController" "C"
我的目标是呈现B并隐藏A,我该如何实现?
我尝试在 C 中设置属性并关闭 A,但它不起作用,因为我关闭了 C 并离开了 A。
AViewController
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showSomething" {
if let destination = segue.destination as? UINavigationController {
if let viewController = destination.viewControllers.first as? CViewController {
viewController.delegate = self
}
}
}
}
CViewController
override func viewDidLoad() {
super.viewDidLoad()
self.delegate.dismiss(animated: false)
}
【问题讨论】: