views:

73

answers:

4

I want to use a UITabBarController but find that very difficult. I have a book that uses it in a giant project where I would have to complete that for a week or so and then find out what parts belong to making the UITabBarController work. Maybe you know of an good article about that?

+3  A: 

I highly recommend going though the View Controller Programming Guide's Tab Bar Controller section. It's full of bare-bones examples and clear explanations.

Ben S
+2  A: 

Here's a full example, and here's the short version:

You can start with a "Navigation-Based Application" and basically swap out the navigation controller for a tab bar controller.

Typically, you'll add a Tab Bar Controller object to your MainWindow.xib (just drag it out of the library and into your view -- after deleting the navigation controller), and hook it to an outlet in your application delegate. In your applicationDidFinishLaunching: add the following line before [window makeKeyAndVisible];:

[window addSubview:tabBarController.view];

(this will probably replace something very similar to what is there by default).

Now you'll want to define the view controllers for each tab. Once you have class files created, go into your MainWindow.xib and add items to your tab bar. For each, change the object type (fourth tab on the inspector) to the class name you've chosen for that particular tab's view controller.

That's it in a nutshell.

Frank Schmitt
+1  A: 

A tab bar is actually pretty easy to understand, once you know the organization.

You have a tab bar controller, into which you can put any number of view controllers. As the tabs are pressed the view controller for that tab will be made active and visible.

The tricky thing to understand is, that NavigationControllers are also ViewControllers. So if you want navigation for any one tab, you have to add a navigation controller which holds the view controller you use for display.

Although you can do tab bar controllers in IB, this is the one area where I think starting by programming them from scratch makes a ton of sense, because you better understand how they are laid out.

Kendall Helmstetter Gelner
A: 

Standford University lectures (run by Apple Engineers) cover this in Lecture 7: http://www.stanford.edu/class/cs193p/cgi-bin/index.php

Scroll down to Lecture 7 which covers Navitgation Controller, Application Data Flow, Customizing Navigation and Tab Bar Controller, and also covering Combining Approaches (i.e. UITabBarControllers and UINavigationControllers together). There's the PDF and if you want to watch the video of the lecture (recommended) then you can find the link to it on iTunes U.

DonnaLea