Check this code for your problem: its working in my application.
- (NSArray *) initializeViewControllers { NSArray *viewControllerArray = nil; viewController1 = <View Init Code> viewController2 = <View Init Code> viewController3 = <View Init Code> 1stNavController = [[UINavigationController alloc] initWithRootViewController:viewController1]; UIImage *img = [UIImage imageNamed:@"tab_home"]; [1stNavController .tabBarItem initWithTitle:@"Home" image:img tag:1]; 2ndNavController = [[UINavigationController alloc] initWithRootViewController:viewController2]; img = [UIImage imageNamed:@"tab_timeDrop"]; [2ndNavController .tabBarItem initWithTitle:@"Time Entry" image:img tag:2]; 3rdNavController = [[UINavigationController alloc] initWithRootViewController:viewController3]; img = [UIImage imageNamed:@"tab_invoiceSummary"]; [3rdNavController.tabBarItem initWithTitle:@"Invoice Summary" image:img tag:3]; viewControllerArray = [NSArray arrayWithObjects:1stNavController,2ndEntryNavController,3rdReportNavController, nil]; return viewControllerArray; }
This code returns View Controllers with images for their respective tabs. Here I used the navigation controller inside the panel controller. You can also use the view controller instead of the navigation controller.
Just add this code and initialize your tab controller as follows inside the appdidfinishlaunching method:
tabbarController = [[UITabBarController alloc] init]; _tabbarController.viewControllers = [self initializeViewControllers]; self.window.rootViewController = tabbarController;
Hope this works.
Please reply.
source share