以编程方式从viewcontroller到tabbar的视图

时间:2014-09-12 12:25:21

标签: ios objective-c uitabbarcontroller tabbar

enter image description here

嗨,这是我的故事板,我想从First view controller转到LoggedinViewController。

我通常使用

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

但如果我添加标签栏控制器这行不起作用,我该如何解决这个问题呢?

3 个答案:

答案 0 :(得分:3)

如果已嵌入导航控制器,则可以使用以下内容。

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];

答案 1 :(得分:0)

为你的tabbarcontroller提供一个来自故事板的标识符,就像这样做

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

希望这有帮助

答案 2 :(得分:0)

首先将“ tabbarid”赋予情节提要中的该标签

onClickHandlerForAdd = price => () => {
    this.setState({ sum: price });
}