我有一个带有多个 Controller 的 MainTabBarController
。
在我的 FirstTabViewController
(嵌入 UINavigationController
)中,我推送到另一个 View Controller ,例如:navigationController?.pushViewController(secondViewController, animated: true)
。
在这个 Controller 中,我必须展示一个模态视图 Controller ,例如:
let vc = self.storyboard!.instantiateViewController(withIdentifier: "SomeViewController") as! SomeViewController
vc.modalPresentationStyle = .overFullScreen
vc.modalTransitionStyle = .coverVertical
let nav = UINavigationController(rootViewController: vc)
self.present(nav, animated: true, completion: nil)
在 SomeViewController
中,我必须像这样关闭这个 Controller :self.dismiss(animated: true)
但它会自动弹出到 Root View Controller (FirstTabViewController
).
我的问题,为什么?
谢谢。
最佳答案
在当前 Controller 而不是 navigationController
上呈现 SomeViewController
。
所以换行:
self.navigationController?.present(nav, animated: true, completion: nil)
收件人:
self.present(nav, animated: true, completion: nil)
关于ios - 从模态中关闭 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43937559/