// UITabBarController 초기화
UITabBarController *tabBarController = [[UITabBarController alloc] init]; 
tabBarController.customizableViewControllers = nil;
  
// 3개의 다른 UIViewController 생성
// 3개의 뷰는 UINavigationController를 사용합니다.
UIViewController *View1 = [[UIViewController alloc] init];
UINavigationController *tab1Controller = [[UINavigationController alloc] initWithRootViewController:View1];
tab1Controller.tabBarItem.image = [UIImage imageNamed:@"1.png"];
[View1 release];
  
UIViewController *View2 = [[UIViewController alloc] init];
UINavigationController *tab2Controller = [[UINavigationController alloc] initWithRootViewController:View2];
tab2Controller.tabBarItem.image = [UIImage imageNamed:@"2.png"];
[View2 release];
  
UIViewController *View3 = [[UIViewController alloc] init];
UINavigationController *tab3Controller = [[UINavigationController alloc] initWithRootViewController:View3];
tab3Controller.tabBarItem.image = [UIImage imageNamed:@"3.png"];
[View3 release];
  
tabBarController.viewControllers = [NSArray arrayWithObjects: tab1Controller, tab2Controller, tab3Controller, nil];

[tab1Controller release];
[tab2Controller release];
[tab3Controller release];

/*
// 또는 아래와 같이 객체들을 넣어도 된다.
NSMutableArray *mutableArray = [[NSMutableArray alloc] initWithCapacity:3];
[mutableArray addObject:UIViewController or UINavigationController]; 반복
[UIViewController or UINavigationController release];
tabBarController.viewControllers = mutableArrary;
*/
  
[window addSubview: tabBarController.view];

.....This article is posted by whitesnake.
1 ··· 16 17 18 19 20 21 22 23 24 ··· 176