使用 UITabBar 是一个很好的解决方案。您可以将 4 个 ViewControllers 放在 UITabBarController 中。从你的 MainViewCONtroller 你可以像这样启动它
UITabBarController *controller = [[UITabBarController alloc]init];
controller.viewControllers = @[vc1,vc2,vc3,vc4];
NSArray *items = controller.tabBar.items ;
UITabBarItem *item1 = [items objectAtIndex:0];
UITabBarItem *item2 = [items objectAtIndex:1];
UITabBarItem *item3 = [items objectAtIndex:2];
UITabBarItem *item4 = [items objectAtIndex:3];
item1.image = [UIImage imageNamed:@"image for vc1"];
item2.image = [UIImage imageNamed:@"image for vc2"];
item3.image = [UIImage imageNamed:@"image for vc3"];
item4.image = [UIImage imageNamed:@"image for vc4"];
item1.title = @"Title1" ;
item2.title = @"Title2" ;
item3.title = @"Title3" ;
item4.title = @"Title4" ;
[self.navigationController pushViewController:controller animated:YES];
现在,您还需要在任何 viewController 或 MainViewController 之间切换。您可以通过按导航返回按钮返回 MainViewController。当然,当您切换到 TabBar 中的另一个 ViewController 时,也会有一些事件。为此,您可以使用它,
self.tabBarController.selectedIndex = 2 ; // To select ViewController 3 from any of VC1 , VC2 , VC4