UITabBarController *tabbarVC = [[UITabBarControlleralloc] init];
OldViewController *oldC = [[OldViewController] init];
oldC.tabBarItem.title = @"控制器1";
oldC.tabBarItem.image = [UIImageimageNamed:@"old.png"];
NewViewController *newC = [[NewViewController] init];
newC.tabBarItem.title = @"控制器2";
newC.tabBarItem.image = [UIImageimageNamed:@"new.png"];
// 添加子控制器(这些子控制器会自动添加到UITabBarController的viewControllers数组中)
[tabbarVC addChildViewController:recent];
[tabbarVC addChildViewController:friends];
[self.navigationController pushViewController:newC animated:YES];
[self.navigationController popViewControllerAnimated:YES];
[self.navigationController popToRootViewControllerAnimated:YES];
[self presentViewController:newC animated:YES completion:nil];
[self dismissViewControllerAnimated:YES completion:nil];
原文:https://www.cnblogs.com/CH520/p/9565196.html