2.這裡用代碼動態實現次功能
貼上效果圖(項目中的一部分,我就不單獨分離出來了)
vcnPtPrC6zwvcD4KPHA+PHByZSBjbGFzcz0="brush:java;"> //定義一個UITabBarController
UITabBarController *dishAndCartTBC=[[UITabBarController alloc]init];
HHDishTypesViewController *dishTypeVC=[[HHDishTypesViewController alloc]init];
dishTypeVC.tabBarItem.title=@"菜單";
dishTypeVC.tabBarItem.image=[UIImage imageNamed:@"navigation_menu_1.png"];
HHCartViewController *cartVC=[[HHCartViewController alloc]init];
cartVC.tabBarItem.title=@"購物車";
cartVC.tabBarItem.image=[UIImage imageNamed:@"navigation_cart_1.png"];
//UITabBarController填充ViewController
dishAndCartTBC.viewControllers=[NSArray arrayWithObjects:dishTypeVC,cartVC, nil];
dishAndCartTBC.hidesBottomBarWhenPushed=YES;
[self.navigationController pushViewController:dishAndCartTBC animated:YES];
具體實現方法就是:1.定義一個UITabbarController
2.定義裝載的兩個ViewController
3.把定義的兩個Viewcontroller放進UITabbarController裡面
4.使用push方法進入UItabbarController,搞定