- (void) initTabBarItems
{
self.iTabBarController = [[UITabBarController alloc] init];
//定义数组,数组保存导航控制器。本例为4组导航控制器
NSArray *array = [[NSArray alloc] initWithObjects:self.iNavDIYController,self.iNavMySchemeViewController,self.iNavHotSchemeViewController,self.iNavSetViewController, nil];
//设置viewControllers属性为导航控制器数组
self.iTabBarController.viewControllers = array;
//设置每个item样式
UIImage *image = [UIImage imageNamed:@"icon_diy.png"];
self.iTabDIYItem = [[UITabBarItem alloc]initWithTitle:@"模拟攒机" image:image tag:0];
self.iPubDIYController.tabBarItem = self.iTabDIYItem;
UIImage *image1 = [UIImage imageNamed:@"icon_my.png"];
self.iTabMySchemeItem = [[UITabBarItem alloc] initWithTitle:@"我的方案" image:image1 tag:0];
self.iPubMySchemeViewController.tabBarItem = self.iTabMySchemeItem;
UIImage *image2 = [UIImage imageNamed:@"icon_hot.png"];
self.iTabHotSchemeItem = [[UITabBarItem alloc] initWithTitle:@"热门方案" image:image2 tag:0];
self.iPubHotSchemeViewController.tabBarItem = self.iTabHotSchemeItem;
UIImage *image3 = [UIImage imageNamed:@"icon_set.png"];
self.iTabSetItem = [[UITabBarItem alloc] initWithTitle:@"设置" image:image3 tag:0];
self.iPubSetViewController.tabBarItem = self.iTabSetItem;
self.iTabBarController.selectedIndex = 0;
}
隐藏导航栏方法
1。在push到下一个Controller中或者viewDidDisappear中加入,隐藏Controller的tabBar
self.hidesBottomBarWhenPushed = NO;
或者
self.controller.hidesBottomBarWhenPushed = NO;