0

According to the answer in here, I need to set title to each of the ViewControllers that's referred in the TabBarController. Yes, I understand that. But when I use NavigationController, I can't seem to change the items' title even though I have set the title of both the NavigationController and the RootViewController of the NavigationController to 'Connections' in the screen shot.

Interface Builder Screenshot

The result in the TabBarController is just Item 1, Item 2, and Item 3, not Connections, Org, and Chats, as I expected.

What did I do wrong? How to do it? Thanks.

Community
  • 1
  • 1
Chen Li Yong
  • 5,459
  • 8
  • 58
  • 124
  • but tabbarviewcontroller already give navigation bar so than why you want navigation controller – Jigar Apr 13 '16 at 03:36
  • You can try adding a UITabBarItem from the Object Library to the UITabBarController. From there you can add a title and image as you need. – Rachel Fong Apr 13 '16 at 04:31
  • @DarjiJigar I want to create same structure like facebook app for iOS. – Chen Li Yong Apr 13 '16 at 05:04
  • @rach sorry, the tabbar of the UITabBarItem is uneditable (e.g. I can't drag and place any UITabBarItem from the Object Library to the tabbar). – Chen Li Yong Apr 13 '16 at 05:08
  • Hold on. I seem to have misunderstood your question. You wanted the tab bar items to have a title right? As in, from the screen caps you posted in your questions, there are dark grey areas on the bottom of your Connection,Org & Chat NavigationControllers. You want them to have an title right? Just to wrap my head around this question. – Rachel Fong Apr 13 '16 at 06:48
  • Actually my previous answer was a little off. I meant to ask you to drag a UITabBarItem to your NavigationControllers on the Storyboard and then set their title from there. – Rachel Fong Apr 13 '16 at 06:53
  • @rach ooooh! It's working! That was an unintuitive way of Apple to design the Interface Builder. -_- anyway, you should make it an answer, so I can choose it as a correct answer! – Chen Li Yong Apr 13 '16 at 07:12
  • 1
    Sure. I shall work on it and include some image captures so as to help others who might run into the same problem. But yes, I agree. Some things in XCode can be counter-intuitive but it is much easier nowadays compared to the earlier versions. :) – Rachel Fong Apr 13 '16 at 07:17
  • @rach nice! I shall await for the full answer! :D – Chen Li Yong Apr 13 '16 at 07:18
  • 1
    Thank you very much for taking your time to explain your problem. Cheers. – Rachel Fong Apr 13 '16 at 07:32

2 Answers2

3

In order to work around this issue, the quickest and most direct way of solving this is via the storyboard. With the structure posted by question, you can simple drag a UITabBarItem to the NavigationController (not the UITabBarController) and XCode you should be able to customise the TabBarItems with titles and images. It should look something like this:

TabBarItem title

Rachel Fong
  • 730
  • 1
  • 8
  • 16
0

To set title of a view controller from storyboard

  • Select a view controller.
  • Double tap a on navigation bar that is appeared after setting root view controller.
  • And finally set your desired title.

Other way is just select a view controller for which you wish to change title after that select navigation bar, go to Attribute Inspector and set title.

Mahendra
  • 8,448
  • 3
  • 33
  • 56
  • The problem is that I have clicked on the Navigation Controller (not View Controller), and then I tried to double tap (or select) the navigation bar of that Navigation Controller, but I can't select it so I can set the desired title on the Attribute Inspector. This is Navigation Controller we're talking about, not View Controller. – Chen Li Yong Apr 13 '16 at 06:35