views:

1913

answers:

1

I was answered how to set images in general for a uitabbarcontroller. however my uitabbarcontroller is an array of views that looks like:

          tabBarController = [[UITabBarController alloc] init];          

viewTab1controller = [[ViewTab1Controller alloc] initWithNibName:@"ViewTab1" bundle:nil];
viewTab1controller.title = @"Schedules";
navigationTab1Controller = [[[UINavigationController alloc] initWithRootViewController:viewTab1controller] autorelease];
[viewTab1controller release];

viewTab2controller = [[ViewTab2Controller alloc] initWithNibName:@"ViewTab2" bundle:nil];
viewTab2controller.title = @"Nearest Stop";
navigationTab2Controller = [[[UINavigationController alloc] initWithRootViewController:viewTab2controller] autorelease];
[viewTab2controller release];

viewTab3controller = [[ViewTab3Controller alloc] initWithNibName:@"ViewTab3" bundle:nil];
viewTab3controller.title = @"Routes";
navigationTab3Controller = [[[UINavigationController alloc] initWithRootViewController:viewTab3controller] autorelease];
[viewTab3controller release];

viewTab4controller = [[ViewTab4Controller alloc] initWithNibName:@"ViewTab4" bundle:nil];
viewTab4controller.title = @"Feedback";
navigationTab4Controller = [[[UINavigationController alloc] initWithRootViewController:viewTab4controller] autorelease];
[viewTab4controller release];

//viewTab5controller = [[ViewTab5Controller alloc] initWithNibName:@"ViewTab5" bundle:nil];
//navigationTab5Controller = [[[UINavigationController alloc] initWithRootViewController:viewTab5controller] autorelease];
//[viewTab5controller release];

tabBarController.viewControllers = [NSArray arrayWithObjects: 
         navigationTab1Controller, 
         navigationTab2Controller, 
         navigationTab3Controller, 
         navigationTab4Controller, 
         //navigationTab5Controller,

I was given the code in the previous answer to add an image to a tabbaritem:

        viewController.tabBarItem.image = [UIImage imageNamed:@"foo.png"];

However this doesn't specify the specific tabbbaritem.

How do I assign an image to each of these 4 tabs?

Thanks! nil];

+3  A: 

Do it like this for each View Controller that you'll be adding to your Tab Bar:

viewTab1controller = [[ViewTab1Controller alloc] initWithNibName:@"ViewTab1" bundle:nil];
viewTab1controller.title = @"Schedules";

navigationTab1Controller = [[[UINavigationController alloc] initWithRootViewController:viewTab1controller] autorelease];
navigationTab1Controller.tabBarItem.image = [[UIImage imageNamed:@"Match.png"] autorelease];

[viewTab1controller release];