Reputation: 53
I have multiple views, some of which are part of tabBarControllers, and the views are pushing to one view controller called View2
. When I go back to the view that presented view2, how would I go back to a specific tab in the tab bar instead of going to the first one?
My action for the button that goes back to the first view is
-(IBAction)goBackButton:(id)sender
{
ViewController *firstView = [myStoryboard instantiateViewControllerWithIdentifier:@"view1"];
[self presentViewController:firstView animated:YES completion:nil];
}
So ViewController is the class of the first view in the tab bar, and the tabBarController has the identifier "view1"
Upvotes: 1
Views: 3024
Reputation: 928
If View2
has been pushed then your backbuttons action should call:
[self.navigationController popViewControllerAnimated:YES];
If View2
is a modal then your backbuttons action should call:
[self dismissViewControllerAnimated:YES completion:nil];
And whichever scene called View2
will reappear for you.
Upvotes: 5