我正在构建这样的流程
FirstViewController -> SecondViewController -> Tab Bar View Controller(由1.ThirdViewController和2.FourthVIewController组成)
我正在打开标签栏 View Controller 作为 SecondViewController 的弹出窗口。但是,当我在 ThirdViewController 中单击一个按钮运行 (self.dismiss(animated: true, completion: nil)) 时,它会返回到 FirstViewController。 我想回到 SecondViewController
添加代码。 这就是我从 SecondViewController 打开标签栏 View Controller 的方式
let popupVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "tabBarVC") as! UITabBarController
self.addChildViewController(popupVC)
popupVC.view.frame = self.view.frame
self.view.addSubview(popupVC.view)
popupVC.didMove(toParentViewController: self)
这就是我尝试从 Third View Controller 关闭标签栏 View Controller 的方式
self.dismiss(animated: true, completion: nil))
最佳答案
您在 secondViewController 中添加了 tabBarController 作为 subview 。因此,您需要从 super View 中删除该 tabBarController View 。
为此,您需要一个 tabBarController 对象。
self.tabBarController?.view.removeFromSuperview()
关于ios - 如何在单击按钮时关闭选项卡栏 Controller 并返回到上一个 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43813965/