//
//
WYYTabBarController.m
//
test1
//
//
Created by chengyou on 16/1/18.
//
#import
"WYYTabBarController.h"
@implementation
WYYTabBarController
-(void)viewDidLoad{
[super viewDidLoad];
[self setUpAllChildViewController];
}
-(void)
setUpAllChildViewController{
//1.添加第一個(gè)控制器
WYYOneViewController *oneVc = [[WYYOneViewController alloc]
init];
[self setUpAllChildViewController:oneVc
image:[UIImage imageNamed:@"tab_home_icon"]
title:@"首頁(yè)"];
//2.添加第二個(gè)控制器
WYYTwoTableViewController *twoVc = [[WYYTwoTableViewController alloc]
init];
[self setUpAllChildViewController:twoVc
image:[UIImage imageNamed:@"js"]
title:@"通訊錄"];
//3.添加第三個(gè)控制器
WYYThreeTableViewController *threeVc =
[[WYYThreeTableViewController alloc]
init];
[self setUpAllChildViewController:threeVc
image:[UIImage imageNamed:@"qw"]
title:@"辦公"];
//4.1加載storyboard,這里僅僅是加載名稱為WYYFourViewController的storyBoard,,并不會(huì)創(chuàng)建storyBoard中的控制器和空間
UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"WYYFourViewController" bundle:nil];
//4.2創(chuàng)建storyBoard中箭頭指向的控制器(初始控制器)
WYYFourViewController *fourVc = [storyBoard instantiateInitialViewController];
//4.3添加第四個(gè)控制器
[self setUpAllChildViewController:fourVc
image:[UIImage imageNamed:@"user"]
title:@"設(shè)置"];
}
#pragma
mark -- 添加一個(gè)子控制器的方法
-(void)setUpAllChildViewController:(UIViewController
*)viewController image:(UIImage *)image
title:(NSString *)title{
UINavigationController *navC = [[UINavigationController alloc]
initWithRootViewController:viewController];
navC.title = title;
navC.tabBarItem.image
= image;
[navC.navigationBar setBackgroundImage:[UIImage imageNamed:@"commentary_num_bg"]
forBarMetrics:UIBarMetricsDefault];
viewController.navigationItem.title
= title;
[self addChildViewController:navC];
}
@end
|