UITabBarController and UINavigationController together???

Discussion in 'iOS Programming' started by belsokar, Aug 8, 2008.

  1. belsokar macrumors member

    Jul 21, 2005
    I have successfully created an application based on a UINavigationController that drills down a few levels from TableView to another TableView to a standard UIView.

    I now want to create a UITabBarController application, and have one of those tabbed views point to my existing UINavigationController that I have already setup...I am having an incredibly difficult time doing so however. I tried setting my existing UINavigationController to be reference from the actual view within the Tab Bar...but that didn't work.

    I then tried within interface builder...if you select the UITabBarController item attributes, you can change the various views to one of the following (View Controller, Navigation Controller, Table View Controller, or Image Picker Controller). I selected Navigation Controller, but then I can't figure out how to link that Navigation Controller object back to my existing classes.

    Any ideas or pointers would be great!
  2. alankernel macrumors newbie

    Jan 3, 2009
    UITabBarController and UINavigationController together???

    Did you get your problem resolved? I'm facing the same issue.

    I would appreciate it if you can share sample code that has a Tab Bar at the top and at least one of its tab items is associated with a navigation controller and others maybe with regular view controllers or navigation controllers. Then, each of the navigation controllers drills down into other views through tables.

    I'm new to iPhone development and this IB connection activity is really confusing me. I can't seem to find a good document that summarizes it and puts things in context.


  3. stadidas macrumors regular

    Feb 27, 2006
    Kent, United Kingdom
    You are almost there. Where you have changed the view type in the tab view to NavigationController, you need to select this navigation controller and set it from an instance of UINavigationController to your navigation view controller subclass.
  4. alankernel macrumors newbie

    Jan 3, 2009
    Tab Bar with Navigation and Table Views.


    Can you please clarify?
    In my case, I created a navFooCtrlr.h/m as follows:


    #import <UIKit/UIKit.h>
    @class navDetailCtrlr;

    @interface navFooCtrlr : UINavigationController <UITableViewDelegate, UITableViewDataSource> {

    NSArray *list;
    FooDetailCtrlr *childController; //this is supposed to be a detail view which will be called when I click on one of the rows in the table


    @property (nonatomic, retain) NSArray *list;



    #import "navFooCtrlr.h"
    #import "FooDetailCtrlr.h"
    #import "NavFooDelegate.h"

    @implementation navFooCtrlr
    @synthesize list;

    //etc etc..

    - I created a new IB navFoo.xib and I set its class to navFooCtrlr in its Class Identity tab. The navFoo.xib contains a table view that is populated with a list of names.

    The problem is that it seems to be launching the view but I don't see the table entries. If I link the table view in a xib file directly under the tab bar item, it displays the table data.

    This may be a very easy issue but considering that I'm fairly new to iPhone programming, I'm probably missing something trivial.


  5. sanPietro98 macrumors 6502a


    May 30, 2008
    I got this to work by following Apple's sample code from "The Elements" project in the Developer Connection site.
  6. stadidas macrumors regular

    Feb 27, 2006
    Kent, United Kingdom
    I have a similar concept to you in one of my projects. My MainWindow.xib contains a TabBarController. Most of the tabs then contain a navigation controller, and the default view of the navigation controllers is a view that contains a table view. Look at the attached image - in my case SummaryViewController is the controller of the SummaryView.xib containing the table view. In your case, substitute SummaryViewController for navFooCtrlr.

    Attached Files:

Share This Page