Reputation: 3637
It's easier to show you a drawing and then explain.
Dashboard Storyboard
I have 2 separate UIViewControllers
(i've included just one in the drawing, the other is irrelevant) embedded in container view called ContainerViewController
.
Post Storyboard
NewPostViewController
shows a UIButton
that presents TextPostViewController
. As you can see, all of them are embedded in UINavigationControllers
. Now, once the completion block of the new post is being called, I have to present the ContainerViewController
and it needs to handle it's own logic. The problem is that it's embedded in UINavigationController
and once I present it, the UITaBbar
is hidden.
I tried to do this:
self.performSegue(withIdentifier: "TextPostToNavContainerVC", sender: nil)
The transition is successful but I'm losing the UITabBar, even though in the DashboardViewController
and the ContainerViewController
I called:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
tabBarController?.tabBar.isHidden = false
}
What am I doing wrong or is there are better way to do that?
Upvotes: 0
Views: 50
Reputation: 24
You should instantiate the tab bar controller. not the view controller. Imagine you're putting a initial view controller ahead of your tab bar controller. Making your tab bar not being pushed
If I undestand it correctly. You are doing this Segue connect to a view controller But you should actually do this Segue connected to a tab bar controller
Upvotes: 1
Reputation: 100549
You can try to add it as a child to control it's frame like this
let textPost = self.storyboard?.instantiateViewController(withIdentifier: "containerID") as! TextPostToNavContainerVC
textPost.view.frame = CGRect(x:20,y:0,width:self.view.frame.width,height:self.view.frame.height-50)
self.view.addSubview(nvc.view)
self.addChildViewController(textPost)
textPost.didMove(toParentViewController: self)
Upvotes: 0