74
votes

I am creating a tab bar iOS app. The tab bar view controller has two tabs, each of them connected to a view controller.

This how it looks:

enter image description here

I need to add more tabs to the tab controller. I am doing it at the storyboard as follows:

  1. I add a new view controller.
  2. I control-drag from the tab bar controller to the new created view controller.
  3. A window opens and I select Relationship Segue-View Controller.
  4. The segue from the tab bar controller to the new view controller is created.

I think that is the way to do it, but after that the tab bar controller doesn't show any tab icons, the tab bar becomes grey.

Like this:

enter image description here

I need to know what am I doing wrong.

7
try to close and reopen the xcode , after seeing ur ques. I have added 7 view controllers to the tab its working fine. - Pandey_Laxman
@Pandey_Laxman, thank you. I will try to do it right now. - mvasco
@Pandey_Laxman, I have closed and reopened xcode and the same issue happens. Do you think I am doing the needed steps to add the new tab as I told in my question? - mvasco
I followed the same step drag a tabBarController from Library then I see only two tab with two VC so I added more VC and control drag from TabBarVC to VCs then select viewController relations , I am using xcode 5.1.1. - Pandey_Laxman
You can try with a new demo project - Pandey_Laxman

7 Answers

146
votes

First drag A TabBarController from Object Library you see that only two tabs with thier VC there.

to add more Tab Item in TabBarVC drag VC from Object Library

Then Control drag from TabBarVC to Newly VC then Segue relation pop ups

Select last one Relationship Segue -> View Controllers

Here is the Screen

7
votes

I had the same problem until I added a tab bar item from the object library into the new view (settings its attributes on the right hand panel) and THEN ctrl dragged from the tab bar controller to the new view, creating a relationship segue.

If I tried to ctrl drag from the tab controller without first adding a tab item to the new view, it had the behaviour you described.

4
votes

be sure to check the size of your icon image. the tint of image added is grey by default. If you have a large sized tab bar image, it can look like the whole tab bar is greyed out for some reason. pic does not auto resize.

1
votes

bellow process is follow in Xcode 9.4 for adding new item in tab bar controller. 1)Drag and Drop new Tab Bar Controller into sotrtyboard 2)It will show 2 item which connected with 2 view controller. 3)For adding third item button in tab bar controller i) Add new View Controller. ii) Right click on Tab Bar Controller and Drag into new view controller. iii) one option popup will display inside that popup select "view controllers" options

It will create relationship link and will generate automatic item button in tab bar controller.

0
votes

need to add/drag icon (from showing the media library) to the 3rd view controller, so that it can display properly.

0
votes

Restarting Xcode 6.1.1 solved the issue for me while I was working on multiple projects.

0
votes

go t0 library and choose tabbar controller then drag and drop after that take another uiviewcontroller and then click on tabbar and control and right click then drag and drop in the uiviewcontroller then you see some options where you have to choose in the relationship segue -> view controller

for more clearance see these images

enter image description here