Tab bar icon and title not showing with Storyboard References

12,901

Solution 1

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

Solution 2

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.

Solution 3

The problem is that in the target view controller, you don't have a UITabBarItem in the views hierarchy. The TabBarItem is related to the storyboard reference, but should be related to the View Controller.

Looks like a "bug" in Xcode...

To resolve this you can do the following:

  • Just create the segues from the UITabBarController to the Storyboard references.
  • You may configure the Tab Bar Items in the storyboard references, they don't do much more other than showing the tabs in the tab bar on the Storyboard, which is nice for development purposes.

If you now run the app, you will indeed notice that the tabs are missing. To get the tabs to display in the running app as well, do this:

  • Go to the viewcontroller the storyboard reference is referencing to
  • Add a Tab Bar Item into this View Controller by dragging it from the Object Library into the View Controller
  • You will now see a tab bar with one single tab in the view controller
  • Configure the tab bar item to show the correct title and icon

Now run the app and you will now see your tabs.

In interface builder, find the Tab Bar item in the Object Library

Drag the Tab Bar item into your the destination view controller by following the storyboard reference

Solution 4

I tried adding another tab bar, then added tab bar item, selected and image for it BUT Non of above seemed to work with my case .. it was like this : Other VC tabs were showing tabBar icons properly but one that i refactored was missing its icon

Then i compared it with VC that were working properly with TabBar icons.. enter image description here

later i found that my navigation items and tab bar items were not together :

The Tab bar item was inside with Navigation Bar.... i dragged the tabBar item to HomeVC and placed with NavigationBar item

Now its working :):)

enter image description here

Solution 5

After struggling with this problem for a few days I found this solution. Double click the storyboard link, which will open the referenced storyboard. In the scene navigator, you can edit the bar item with a custom title and icon. Works in xCode 9.

Storyboard

Scene Navigator

Share:
12,901
MVZ
Author by

MVZ

Updated on June 06, 2022

Comments

  • MVZ
    MVZ about 2 years

    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?