Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 从viewcontroller转到tabbar';以编程方式创建视图_Ios_Objective C_Uitabbarcontroller_Tabbar - Fatal编程技术网

Ios 从viewcontroller转到tabbar';以编程方式创建视图

Ios 从viewcontroller转到tabbar';以编程方式创建视图,ios,objective-c,uitabbarcontroller,tabbar,Ios,Objective C,Uitabbarcontroller,Tabbar,嗨,这是我的故事板,我想从第一视图控制器转到LoggedinViewController UIStoryboard *myStoryBoard =[UIStoryboard storyboardWithName:@"Story_Board_Name" bundle:nil]; UITabBarController *tabBarController = [myStoryBoard instantiateViewControllerWithIdentifier:@"TABid"]; self.t

嗨,这是我的故事板,我想从第一视图控制器转到LoggedinViewController

UIStoryboard *myStoryBoard =[UIStoryboard storyboardWithName:@"Story_Board_Name" bundle:nil];
 UITabBarController *tabBarController = [myStoryBoard instantiateViewControllerWithIdentifier:@"TABid"];
self.tabBarController.selectedIndex = 0;
 [self.navigationController pushViewController:self.tabBarController animated:YES];
我通常使用

[self performSegueWithIdentifier:@"s1" sender:self];

但是,如果我添加了tab bar控制器,这行代码不起作用,我如何修复它?

从情节提要中为tab bar控制器指定一个标识符,然后执行类似的操作

 UIStoryboard *myStoryBoard =[UIStoryboard storyboardWithName:@"Your_Story_Board_Name" bundle:nil];
 TabViewController *tabBarController = [myStoryBoard instantiateViewControllerWithIdentifier:@"TAB_Identifier"];
 [self presentViewController:tabBarController animated:YES completion:nil];  

希望这对您有所帮助

如果您已嵌入导航控制器,则可以使用以下功能

UIStoryboard *myStoryBoard =[UIStoryboard storyboardWithName:@"Story_Board_Name" bundle:nil];
 UITabBarController *tabBarController = [myStoryBoard instantiateViewControllerWithIdentifier:@"TABid"];
self.tabBarController.selectedIndex = 0;
 [self.navigationController pushViewController:self.tabBarController animated:YES];
或者试试这个

UIStoryboard *myStoryBoard =[UIStoryboard storyboardWithName:@"Story_Board_Name" bundle:nil];
 UITabBarController *tabBarController = [myStoryBoard instantiateViewControllerWithIdentifier:@"TABid"];
self.tabBarController.selectedIndex = 0;
[self performSegueWithIdentifier:@"s1" sender:self];
首先将“tabbarid”赋予故事板中的选项卡

UITabBarController *tabBarController1 = [self.storyboard instantiateViewControllerWithIdentifier:@"tabbarid"];
    tabBarController1.selectedIndex = 1;
    [self presentViewController:tabBarController1 animated:YES completion:nil];

如果
LogedViewController
嵌入了
UINavigationController
,该怎么办?在这种情况下,上层代码不起作用。在我使用此代码的场景中,它会将我带到
UITabbarController
,但不能通过按它们转到其他选项卡。看起来冷极了。我的解决方案是什么?谢谢