ContainerView with multiple embed segues

前端 未结 7 1996
走了就别回头了
走了就别回头了 2021-01-30 10:38

Is there a way to have a single ContainerView with multiple embed segues? The aim is for a ContainerView to hold a few different ViewControllers depending on what buttons have b

7条回答
  •  北恋
    北恋 (楼主)
    2021-01-30 11:05

    Yes, I was able to achieve what you're looking for inspired by @rdelmar post. What you need to do is to embed a UITabBarViewController into your container view. Then you programmatically choose which controller you like to present. You might also like to hide the tab bar.

    If you want you can also hide the tab bars seen in the storyboard file

    You can choose the view controller you want to present by subclassing the UITabBarController:

    override func viewDidLoad() {
        super.viewDidLoad()
        self.selectedIndex = 1
    }
    

    You can hide the tab bar in your view controller by calling self.tabBarController?.tabBar.hidden = truein viewDidLoad().

提交回复
热议问题