1. It is wrong to say that building UITabBarController in ViewController is not feasible on the Internet,
2. Use the code to dynamically implement the function.
Paste (I will not separate a part of the project)
Handler + handler = "brush: java;"> // define a UITabBarController * dishAndCartTBC = [[UITabBarController alloc] init]; HHDishTypesViewController * dishTypeVC = [HHDishTypesViewController alloc] init]; dishTypeVC. tabBarItem. title = @ "menu"; dishTypeVC. tabBarItem. image = [UIImage imageNamed: @ "navigation_menu_1.png"]; HHCartViewController * cartVC = [[HHCartViewController alloc] init]; cartVC. tabBarItem. title = @ "Shopping Cart"; cartVC. tabBarItem. image = [UIImage imageNamed: @ "navigation_cart_1.png"]; // fill in ViewController dishAndCartTBC with UITabBarController. viewControllers = [NSArray arrayWithObjects: dishTypeVC, cartVC, nil]; dishAndCartTBC. hidesBottomBarWhenPushed = YES; [self. navigationController pushViewController: dishAndCartTBC animated: YES];
The specific implementation method is: 1. Define a UITabbarController
2. Define Two mounted viewcontrollers
3. Put the two defined viewcontrollers into UITabbarController
4. Use the push method to access UItabbarController.