I would like to add a TabBar to an existing view-based application I already started just to allow the user to switch to other parts of the app like the “About” section and another section entitled “Saved Searches” to display a navigational content (saved searches list > specific search result > product details).
Any idea on how to do this ? All tutorials I found point me directly to a TabBar template.
Thx for helping,
Stephane
You can create a new
UITabBarController, and add it’s view as a subview of your applications window. Then, add your other view controllers (for your “About” and “Saved Searches” sections) to that tab bar controller.This can be done most easily in Interface Builder. In your
MainWindow.xib, drag a Tab Bar Controller object onto the canvas. This will automatically create a tab bar with two items (one for each of the view controllers added). For each view controller under the tab bar controller, go to the identity inspector and change its class to your custom view controller subclass. Then, show the attributes inspector and there is a field “NIB Name” – again, set this to the appropriate nib name. Your custom controller views will then be loaded from their corresponding nib files. All that’s left to do is name each tab in Interface Builder, and give it a graphic.You can also do this programmatically if you don’t like IB, by assigning the custom view controllers to the tab controller’s
viewControllersproperty, and assign aselectedViewController.Hope this helps.
EDIT
Thought it might be helpful to show a little hierarchy! Your
MainWindox.xibstructure might look something like this:And push appropriate view controllers from SavedSearchesViewController as normal to provide navigation content.