我开始使用TabBarController开发我的应用程序,但我最近意识到在访问应用程序之前使用身份验证用户。所以我在TabBarContoller之前创建了一个登录页面(2个标签和2个视图)。但是现在我无法将控制器从ViewController推送到TabBarController。 到目前为止我尝试过的是:(用户点击登录页面上的提交按钮后):
UIStoryboard* sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController* vc = [sb instantiateViewControllerWithIdentifier:@"twoOptions"];
[self.navigationController pushViewController:vc animated:YES];
这里,twoOptions是我在界面生成器中为StoryBarController在StoryBoard中命名的标识符
请指导我
我浏览了以下链接: ViewController to TabBarController但仍然不明白需要做什么。我无法推送视图
答案 0 :(得分:0)
UITabBarController *tabBarController=[[UITabBarController alloc]init];
tabBarController.viewControllers = [NSArray arrayWithObjects:firstViewController,secondViewController,thirdViewController, nil];
[self presentModalViewController:tabBarController animated:NO];
我不知道你为什么使用故事板,但也可以使用代码轻松完成。