Check this code for your problem: Its working in my app.
- (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 is returning View Controllers with Images for their respective tabs. Here i used Navigation Controller inside the tabbar controller. you can also use view controller instead of navigation Controller.
Just add this code and initialize your tabbar controller as follows inside appdidfinishlaunching
method:
tabbarController = [[UITabBarController alloc] init];
_tabbarController.viewControllers = [self initializeViewControllers];
self.window.rootViewController = tabbarController;
Hope it works.
Please reply.