Cover by Alasdair Allan

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

Tab Bar Applications

If you need to provide a number of different views on the same data set, or separately present a number of different tasks relating to your application, Apple recommends using a tab bar application. Both the iTunes and the App Store applications that ship with the iPhone and iPod touch are examples of applications that use this pattern.

To create a tab bar application, open Xcode and start a new project. Select Tab Bar Application from the New Project window as the template and name it “TabExample” when requested.

Unlike some of the other application templates provided by Apple, there are actually several different approaches you can take to building a tab bar application: loading a tab’s view from a secondary NIB, managing the tab’s view entirely from a view controller, or using a hybrid of these two approaches.

The default template provides a tab bar application with two tab items, but the way the view is managed for each of these items is very different. Double-click MainWindow.xib (it’s in the Resources group) to open it in Interface Builder. Next, make sure MainWindow.xib is the foremost window and switch to List Mode (⌘-Option-2), then fully expand Tab Bar Controller by Option-clicking the disclosure triangle to its left.

In Figure 6-8 you can see that under the Tab Bar Controller entry is the tab bar itself, and then two view controllers, each with a tab bar item.

Figure 6-8. The MainWindow.xib file generated by Xcode as part of the Tab Bar Application template ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required