tableviewcontroller to tabbarcontroller

Having a tough time trying to push a tabbarcontroller into view from a tableviewcontroller. I don't get any errors, but the tab bar on the tabbarcontroller is empty and the view is black. If I set the tabbarcontroller as 'is initial view controller' it works as expected. So for some reason there is a problem when I try to push the tabbarcontroller into view via code.


I am using swift and XCode 6.3.2.


Any help would be appreciated.

Answered by pga.michael in 9392022

Only solution I could find to this is to use the segue functionality in the storyboard and call it when the cell is clicked.


performSegueWithIdentifier("trialSitesSegue", sender: self)


Different to what I was originally trying to do, but probably the best and simplest solution.

How are you "pusing" it into view? Is the root view controller a UINavigationController?

Pushing a tab bar controller onto a navigation stack is not supported. The tab bar controller should be your application's root view controller (UITabBarController > UINavigation Controller > Table View Controller).


Alternatively, you may present the tab bar controller modally in response to the user tapping on the appropriate row in your table.

Oh wow, I wish I knew that earlier. Is there anywhere in the docs I can find out information like this?


I have quite a bit of navigation between views in my app. I start with a tableviewcontroller to display a list of sites to choose from which will show a tabbarcontroller which can then potentially go to another tabbarcontroller.


Do I need to run with modals for each of these subsequent screens? I also tried adding a tabbar to a viewcontroller, but I couldn't even get the tab bar to display.


Any advice would be appreciated.

ok, i just tried to present the tabbarcontroller with presentViewController and it comes up the same as before (black view with empty tab bar)


i tried setting the tabbarcontroller as initial view controller again, and it still works that way. so its only when i try to present it afterwards it doesnt work.

Accepted Answer

Only solution I could find to this is to use the segue functionality in the storyboard and call it when the cell is clicked.


performSegueWithIdentifier("trialSitesSegue", sender: self)


Different to what I was originally trying to do, but probably the best and simplest solution.

tableviewcontroller to tabbarcontroller
 
 
Q