what are connections need to to be done for tab bar controller in the main window.xib?

53 views Asked by At

help me out with the connections need to be done in the mainwindow.xib for tab bar controller to swith between the tab bar items. i have connected app delegate to tab bar controller. But am unable switch over the multiple views when the tab bar buttons are clicked

1

There are 1 answers

0
Ajeet Pratap Maurya On

Suppose you have 2 tabs on your tabBarController.

In your appDelegate function

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  UIViewController *viewController1 = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];

    UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];

  self.tabBarController = [[UITabBarController alloc] init];

   self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2,nil];

     self.window.rootViewController = self.tabBarController;
     [self.window makeKeyAndVisible];


}

This way you can easily bind your tabBarController. Note: Dont forget to declare tabBarController in your appDelegate.h file.