This tutorial is intended as a primer for my tutorial on Creating a Custom Tab Bar for the iPhone. It is intended for the absolute beginner and doesn’t require a single line of code.
First we will create a new Xcode project using the template called “Tab Bar Application“.
By default the Tab Bar Application only has two tab bar items and two views and for my application I need four items and four views.
To create a new view right click in the file area and select Add > New File.
Select UIViewController sublcass and check the box that says With XIB for user interface
Now we will give the view a name, I am going to name it ThirdView
Repeat the above steps to create another view called FourthView
We need to put a label on each of the views so we know which is which. Double click ThirdView.xib to open interface builder.
Drag a label from the library onto the view and give it some text so we can identify it. I have gone with “Third View” (very original!).
Now save and close it.
Do the same with FourthView.xib (put different text in the label) then save and close it.
Now we are going to add the two new buttons to the Tab Bar. Open up MainWindow.xib
We need to make sure that your IB is in list mode and not icon mode. Your screen should look like the below. If it doesn’t you need to click the list view icon (also highlighted in the image below).
In the inspector click the plus icon to add two new view controllers and name them Third and Fourth respectively.
Now click on the new Tab Bar button you have created.
In the inspector set the NIB Name to ThirdView.
Now repeat for the fourth Tab Bar button and close and save interface builder.
In Xcode you can now select your device as a the simulator and Build and Run and you will have a basic application with four different tabs and views.