76

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.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
mvasco
  • 4,965
  • 7
  • 59
  • 120
  • 3
    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 Apr 28 '14 at 04:57
  • @Pandey_Laxman, thank you. I will try to do it right now. – mvasco Apr 28 '14 at 05:10
  • @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 Apr 28 '14 at 05:21
  • 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 Apr 28 '14 at 05:25
  • You can try with a new demo project – Pandey_Laxman Apr 28 '14 at 05:26
  • @Pandey_Laxman, and the new view controller is a normal view controller, I don't need to add any control there... – mvasco Apr 28 '14 at 05:27
  • @Pandey_Laxman, I am using xcode 5.1, I have created a new Tabbed Application project, and tried to add a new tab, and the same issue: grey tab... – mvasco Apr 28 '14 at 05:30
  • The solution is to add a tab-bar image. – Tom Aug 17 '16 at 08:53

7 Answers7

147

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

Pandey_Laxman
  • 3,889
  • 2
  • 21
  • 39
  • I am doing this like you, but I guess there is a bug in my xcode, then if I add a new tabBarController, the icons are not shown, the tab bar is completely grey, no icons on it. – mvasco Apr 28 '14 at 05:35
  • Actually I am also not able to figure out whats going wrong with you I have also tried option in IB for tabbar bottom bar etc. you can update ur xcode to new version 5.1.1 – Pandey_Laxman Apr 28 '14 at 05:50
  • It must be something wrong there, but now it works after changing the tab bar icon on the new added view controller, just after adding it, the tab bar controller now shows all icons and the grey tab has been removed....thank you in any case. – mvasco Apr 28 '14 at 06:04
  • 1
    nice of you , glad to help you :) you know there are many bug fixes, stability improvement... in xcode update so you should have update tools – Pandey_Laxman Apr 28 '14 at 06:09
  • 1
    In Xcode 11 (as of beta4 at least), you no longer need to add a TabBar Item - simply control-dragging from the TabBar to the target ViewController and selecting "view controllers" from relationship seque will create a TabBarItem for you (default appears to be a custom view) and it'll label the TabBarItem as simply "Item". – heckj Jul 18 '19 at 21:35
7

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.

Tom Manterfield
  • 6,515
  • 6
  • 36
  • 52
  • 1
    Thanks so much for your answer! After trying to solve this your answer was the clue that I was missing – ajk4550 Apr 22 '15 at 15:00
  • 1
    THANK YOU THANK YOU THANK YOU 3 and a half years later! I spent like an hour trying to figure this out. – mlecoz May 27 '18 at 03:20
4

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.

  • This was the solution for me. The default tab bar icon was just a giant grey rectangle as displayed above. Simply changing the image of the Bar Item to the new icon fixed it for me. – Scooter Oct 04 '15 at 00:32
1

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

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

NSTNF
  • 63
  • 10
0

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

Kevin
  • 16,696
  • 7
  • 51
  • 68
0

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

StupidWolf
  • 45,075
  • 17
  • 40
  • 72
keshav
  • 96
  • 7