Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tab bar icon and title not showing with Storyboard References

I have the following storyboard with a segue to a storyboard reference:

enter image description here

The problem is that when I run the app, it doesn't show the icon or the title:

enter image description here

These are the item settings:

enter image description here

What am I missing?

like image 505
MVZ Avatar asked Feb 04 '16 19:02

MVZ


People also ask

How do I add a tab bar to a storyboard?

To add a tab, first drag a new View Controller object to the storybard. Next control-drag from the tab bar controller to new view controller and select view controllers under Relationship Segue . Your tab bar controller will update with a new tab.

What is tab bar in Swift?

The tab bar interface displays tabs at the bottom of the window for selecting between the different modes and for displaying the views for that mode. This class is generally used as-is, but may also be subclassed. Each tab of a tab bar controller interface is associated with a custom view controller.

How do I hide the bottom bar in Swift?

Answer: Use self. tabBarController?. tabBar. hidden instead of hidesBottomBarWhenPushed in each view controller to manage whether the view controller should show a tab bar or not.


2 Answers

Here's how to get the tab to show properly:

  1. Put the first UIViewController that will be embedded in the tab in the same storyboard as the UITabViewController. enter image description here
  2. Ctrl + Drag from the tab bar controller to the content view controller to make the connection as per usual. This will automatically add the UITabBarItem to the bottom of the content view controller. enter image description here
  3. Select the content view controller.
  4. Click the Editor menu and choose Refactor to Storyboard... enter image description here

The UITabBarController tab will now point to the new storyboard reference... enter image description here ... and the content view controller preserves the UITabBarItem from the tab bar relationship. It will appear normally in the app now. enter image description here

like image 72
Drew C Avatar answered Oct 04 '22 20:10

Drew C


You can modify image/title of the tab bar item in the initial view controller of the storyboard you are referring to. You just need to add a 'tab bar item' to the initial view controller and change its properties (title/image) accordingly.

  1. Outline view of the root view controller in the referred storyboard

document outline of referred to storyboard

  1. The modified tab bar item in the view controller

initial view controller with modified tab bar item

Note: the change will not be reflected on the tab bar in the main storyboard; you only see it in the referred storyboard and at runtime.

like image 38
Dries Avatar answered Oct 04 '22 18:10

Dries