programmatically create TABBAR

tabBars = [[UITabBarController alloc] init];
NSMutableArray *localViewControllersArray = 
 [[NSMutableArray alloc] initWithCapacity:4];
HomeTabViewController *ptr_homeTab;
ptr_homeTab
= [[HomeTabViewController alloc] 
initWithNibName:@"HomeTabViewController" bundle:nil];
UINavigationController *homeNavBar=[[UINavigationController alloc] 
initWithRootViewController:ptr_homeTab];
homeNavBar
.tabBarItem.title=@"Home";
homeNavBar
.tabBarItem.image=[UIImage imageNamed:@"home.png"];
[ptr_homeTab release];

myHospitalviewController
=[[MyHospitalViewController alloc]
 initWithNibName:@"MyHospitalViewController" bundle:nil];
UINavigationController *myHospitalNavBar=[[UINavigationController alloc] 
initWithRootViewController:myHospitalviewController];
myHospitalNavBar
.title=@"My Hospital";
myHospitalNavBar
.tabBarItem.image=[UIImage imageNamed:@"myhospital.png"];
[myHospitalviewController release];

viewController
= [[TreatMentiViewController alloc]
 initWithNibName:@"TreatMentiViewController" bundle:nil];
UINavigationController *hospitalNavBar=[[UINavigationController alloc]
 initWithRootViewController:viewController];
hospitalNavBar
.tabBarItem.title=@"Hospital";
hospitalNavBar
.tabBarItem.image=[UIImage imageNamed:@"hospital.png"];
[viewController release];
PersonalMedicineViewController *ptr_PersonalMedicine = 
 [[PersonalMedicineViewController alloc] 
initWithNibName:@"PersonalMedicineViewController" bundle:nil];
UINavigationController *managerNavBar=[[UINavigationController alloc] 
initWithRootViewController:ptr_PersonalMedicine];
managerNavBar
.tabBarItem.title=@"Manager";
managerNavBar
.tabBarItem.image=[UIImage imageNamed:@"manager.png"];
[ptr_PersonalMedicine release];
[localViewControllersArray addObject:homeNavBar];
[localViewControllersArray addObject:h
ospitalNavBar];
[localViewControllersArray addObject:myHospitalNavBar];
[localViewControllersArray addObject:managerNavBar];

[homeNavBar release];
[hospitalNavBar release];
[myHospitalNavBar release];
[managerNavBar release];

tabBars
.viewControllers = localViewControllersArray;
tabBars
.view.autoresizingMask==(UIViewAutoresizingFlexibleHeight);
[localViewControllersArray release];
[window addSubview:tabBars.view];

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>