2.这里用代码动态实现次功能
贴上效果图(项目中的一部分,我就不单独分离出来了)
附上代码
//定义一个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,搞定
ios-开发点滴 在ViewController里面建立UITabBarController,布布扣,bubuko.com