6
votes

I have an application with several view controllers controlled from a tab bar controller. From one of these view controllers I want to (on clicking a button) segue to another view controller and retain the tab bar at the bottom of the segued to view.

I've used

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if ([segue.identifier isEqualToString:@"newView"]){
        UIViewController *controller =segue.destinationViewController;
        controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        [self presentModalViewController:controller animated:YES];
    }
 }

This works fine except the tab bar is missing from the segued to view (a placeholder shows for it in the storyboard, but it doesn't show up when the app is run) I've also tried replacing

[self presentModalViewController:controller animated:YES];

with

[self presentViewController:controller animated:YES completion:nil];

but that doesn't work either.

A bit of debugging shows that for the segued-to view controller, the tabBarController property is set to nil.

Is there anyway to retain the tab bar in the segued-to view controller?

1

1 Answers

1
votes

From your explanation, I don't think you want a modal controller. Modal is used to overlay, rendering your tab bar useless. From your storyboard, select your segue and select push, not modal.

enter image description here

Push vs Modal (Note the tab bar):

enter image description hereenter image description here