Search code examples
iphoneobjective-cuisplitviewcontrolleripad

How to add tab bar controllers to the root view of the split view controller application


enter image description here

I am very new to the iPad UISplitViewController.

I need to add a tab bar containing 3 tabs at the bottom of the master view / left view. I have a different View Controller for each of the 3 tabs. I haven't found any other examples of Tab bars being used in split view based applications.

Where do I insert a tab bar controller for displaying at the bottom of the the root view?

How do I establish a connection so that when I select a table cell, the detailItem info gets displayed in the Detail View? Tab bar was added to the Root View in IB. Should I be adding it programmatically instead?


Solution

  • you have to take UITabBarController dynaically.

    In .h file

    UITabBarController *tabBar;

    in .m file

    create objects to your classes in appDidFinish Launch

    For example you have

    Class1 and Class2

    in appDidFinishLaunch

    Class1 *obj1=[Class1 alloc]initWithNibName:@"Class1" bundle:nil]; **Class2 obj2=[Class2 alloc]initWithNibName:@"Class2" bundle:nil];*

    // Master navigation controller by defaults comes with template code

    // Now you have create Array for tabBar

    NSArray *tabViewArray=[[NSArray alloc] initWithObjects:obj1,obj2,masterNavigationController, nil];

    tabBar=[[UITabBarController alloc] init];

    [tabBar setViewControllers:tabViewArray];

    // now you have to edit the statement which contains splitview.viewArray repalce masterNavigataionControler with tabBar

    self.splitViewController.viewControllers = [NSArray arrayWithObjects:tabBar, detailNavigationController, nil];

    Try this i hope it will helps you.