【发布时间】:2014-11-06 15:13:34
【问题描述】:
嗨,这是我的故事板,我想从 First view controller 转到 LoggedinViewController。
我正常使用
[self performSegueWithIdentifier:@"s1" sender:self];
但是如果我添加标签栏控制器这条线不起作用,我该如何解决这个问题?
【问题讨论】:
标签: ios objective-c uitabbarcontroller tabbar
嗨,这是我的故事板,我想从 First view controller 转到 LoggedinViewController。
我正常使用
[self performSegueWithIdentifier:@"s1" sender:self];
但是如果我添加标签栏控制器这条线不起作用,我该如何解决这个问题?
【问题讨论】:
标签: ios objective-c uitabbarcontroller tabbar
如果您已嵌入导航控制器,则可以使用以下内容。
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];
【讨论】:
LogedInViewController 嵌入了UINavigationController 怎么办?在这种情况下,上层代码不起作用。在我使用此代码的场景中,它会将我带到UITabbarController,但无法通过按下它们转到其他选项卡。它看起来冻结。对我来说有什么解决方案?谢谢
给你的 tabbarcontroller 一个来自故事板的标识符,做这样的事情
UIStoryboard *myStoryBoard =[UIStoryboard storyboardWithName:@"Your_Story_Board_Name" bundle:nil];
TabViewController *tabBarController = [myStoryBoard instantiateViewControllerWithIdentifier:@"TAB_Identifier"];
[self presentViewController:tabBarController animated:YES completion:nil];
希望对你有帮助
【讨论】:
首先将“tabbarid”赋予情节提要内的该选项卡
UITabBarController *tabBarController1 = [self.storyboard instantiateViewControllerWithIdentifier:@"tabbarid"];
tabBarController1.selectedIndex = 1;
[self presentViewController:tabBarController1 animated:YES completion:nil];
【讨论】: