AKM
AKM

Reputation: 31

Load views with tab bar item!

is that possible to bring the view with the help of tab bar item. let me explain you the question clearly.I created view based application. Added two vies let us say first and second. the first view contains a button that takes us to the second view. Second view also contains a button that takes us to the third view. I have added tab bar to the third view and added four tab bar items to it. Now I want to link the tab bar items to the views. Let us say 4th , 5th and sixth.

1st View(Buton) -> 2nd View(button)-->third view (contains tab bar and 4 tab bar items). But all the items have empty views. When I select the tab bar item i have to load .xib files i created. How to link a tab bar item with a view controller so that i can load views. Else , is there any other options to load the views with tab bar items??

Upvotes: 3

Views: 1113

Answers (1)

theChrisKent
theChrisKent

Reputation: 15099

If you mean how do you load the views into a tab bar controller then do something like this:

UITabBarController *tabView = [[UITabBarController alloc] init];
UIViewController *view4 = [[UIViewController alloc] init];
UITabBarItem *view4TabBarItem = [[UITabBarItem alloc] initWithTitle:@"4" image:[UIImage imageNamed:@"icon4.png"] tag:nil];
view4.tabBarItem = view4TabBarItem;
[view4TabBarItem release];
UIViewController *view5 = [[UIViewController alloc] init];
UITabBarItem *view5TabBarItem = [[UITabBarItem alloc] initWithTitle:@"5" image:[UIImage imageNamed:@"icon5.png"] tag:nil];
view5.tabBarItem = view5TabBarItem;
[view5TabBarItem release];
UIViewController *view6 = [[UIViewController alloc] init];
UITabBarItem *view6TabBarItem = [[UITabBarItem alloc] initWithTitle:@"6" image:[UIImage imageNamed:@"icon6.png"] tag:nil];
view6.tabBarItem = view6TabBarItem;
[view6TabBarItem release];
NSArray *viewControllers = [[NSArray alloc] initWithObjects:view4,view5,view6,nil];
[view4 release];
[view5 release];
[view6 release];
tabView.viewControllers = viewControllers;
[viewControllers release];
[self presentModalViewController:tabView animated:YES];
[tabView release];

Upvotes: 1

Related Questions