Reputation: 441
Hi, this is my storyboard , i wanna go from First view controller to LoggedinViewController.
Im normally using
[self performSegueWithIdentifier:@"s1" sender:self];
but if i add tab bar controller this line is not working , how can i fix this ?
Upvotes: 3
Views: 1229
Reputation: 75
first give "tabbarid" to that tab inside storyboard
UITabBarController *tabBarController1 = [self.storyboard instantiateViewControllerWithIdentifier:@"tabbarid"];
tabBarController1.selectedIndex = 1;
[self presentViewController:tabBarController1 animated:YES completion:nil];
Upvotes: 0
Reputation: 937
You can use the following if you have embedded into navigation controller.
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];
Or try this
UIStoryboard *myStoryBoard =[UIStoryboard storyboardWithName:@"Story_Board_Name" bundle:nil];
UITabBarController *tabBarController = [myStoryBoard instantiateViewControllerWithIdentifier:@"TABid"];
self.tabBarController.selectedIndex = 0;
[self performSegueWithIdentifier:@"s1" sender:self];
Upvotes: 3
Reputation: 2176
Give your tabbarcontroller an identifier from the storyboard, the do something like this
UIStoryboard *myStoryBoard =[UIStoryboard storyboardWithName:@"Your_Story_Board_Name" bundle:nil];
TabViewController *tabBarController = [myStoryBoard instantiateViewControllerWithIdentifier:@"TAB_Identifier"];
[self presentViewController:tabBarController animated:YES completion:nil];
Hope this helps
Upvotes: 0