回答

0

假設您的tabBarController上有2個選項卡。

在你的appDelegate功能

- (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]; 


} 

這樣你就可以輕鬆地綁定您tabBarController。 注意:不要忘記在appDelegate.h文件中聲明tabBarController。