首页 > 解决方案 > 关闭 ViewControllers 以返回之前的 ViewController

问题描述

我的故事板设置非常简单。我有两个视图,左边一个是默认的,有时应用程序会切换到第二个视图。

如果不实例化新的根 ViewController,我不会让它切换回来。显然,每次我“关闭”第二个视图控制器时,都会创建一个新的根 ViewController,而不是使用之前存在的那个。我不使用 NavigationControllers,我只想在两个视图之间切换。

我用来呈现第二种观点的东西

let infoView = self.storyboard?.instantiateViewController(withIdentifier: "infoboard") as! InfoBoardViewController
self.present(infoView, animated: false, completion: nil)

我用什么来解雇它

UIApplication.topViewController()?.dismiss(animated: false, completion: nil)

标签: iosswiftstoryboard

解决方案


推荐阅读