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"
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.