Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

problems with tab bar controllers

Hi guys,

i am developing a ribbit like app with two tab bar controllers for two different of users one.

Now when I press on one of the tabbaritems -of one of the two tabbarcontrollers- like the "friends" tab in the Ribbit app, the added "edit" bar button is not visible in the navigation of this tableviewcontroller.

I think the tabbarcontroller wont function well, otherwise it should automatically show the table view controller with the added bar buttons on it right?

here you can see my mainstoryboard https://docs.google.com/document/d/1hQjuJxESVq9c0rWWlURkcF3ckd5Hjga1p468rDxWe1U/edit?usp=sharing

4 Answers

I couldnt solve it, therefore I made two different apps. For eacht tab controller one app.

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

So what exactly happens when you tap on the tab? Is the new view controller loaded, but empty? It's hard for me to tell from your screenshots, but what you seem to be describing sounds like it should work. Tapping on the tab can display a new table view controller that should have bar button items, just like the Friends tab in the Ribbit app.

When i tap on the tab bar item it stays on the tabbarviewcontroller, dont go throug the "friends"table view..but when I change the initial starting arrow to this tabbarcontroller, than it function well...what does that little arrow at the beginning viewcontroller mean in the main storyboard in fact?

Soojin Ro
Soojin Ro
13,331 Points

The arrow indicates which view controller will be shown when you first start the app. If you click a view controller and see the 'attributes inspector', there is a checkbox called "Is Initial View Controller". If you check that box, that view controller becomes the first view of your app.

Ben Jakuben
Ben Jakuben
Treehouse Teacher

It sounds like the tab bar item may not be correctly hooked up to your "friends" table view. You might want to try deleting the segue in your storyboard and then recreating it to make sure you're doing it like in this video. If you hook it up correctly you should at least be able to view the appropriate view controller when you tap on the tab.

I did it like that video, checked again it has to be with the initial function. If i set the initial screen to that particular tabbarcontroller, it function right. When I make the loginviewcontroller the initial vc, than the tabbar wont function well....So...I really dont know how to solve..?

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Ah, I think it may be difficulties in trying to use a tab bar controller that isn't at the root level of your navigation. Apple recommends only using tab bar controllers at the root level (which is the same thing as you moving the entry point arrow). But your storyboard has a regular navigation controller spawning a tab bar controller later on. It's not impossible, but if you google "tab bar controller inside navigation controller" or something like that then you can read more about possible solutions or changes.

Yes, besides that I think the little arrow/initial screen function give different functions to this initial screen...why would otherwise function the tabbarcontroller like it shoulds (if it is set as initial view)....if it is not set as initial view, the tabbarviews wont appear and shows arrow back to the loginvc (root)...which I also dont want...i think that the tabbarcontroller dont function well because it is not the rootvc?