代码方式创建UITabBarController
代码
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];self.window.backgroundColor = [UIColor whiteColor];UITabBarController *tbc = [[UITabBarController alloc] init];UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];OneController *one = [sb instantiateViewControllerWithIdentifier:@"one01"];one.tabBarItem.title = @"one";ViewController *two = [sb instantiateViewControllerWithIdentifier:@"view01"];two.tabBarItem.title = @"two";tbc.viewControllers = @[one , two];self.window.rootViewController = tbc;[self.window makeKeyAndVisible];return YES;
运行效果