Josh Boothe
Josh Boothe

Reputation: 1423

presentViewController not loading tab bar when switch views

When I switch from designworks.xib (designworks.m, designworks.h) to the MainStoryboard FirstViewController (which is a tab bar controller, first controller out of the tabs) it loads the content on the storyboard but it doesnt load in the tab bar navigation at the bottom.

- (IBAction)backToHome:(id)sender {
    /*
    FirstViewController *fvc = [[FirstViewController alloc] initWithNibName:nil bundle:nil];
    [self presentViewController:fvc animated:YES completion:nil];
     */
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    FirstViewController *fvc = [storyboard instantiateViewControllerWithIdentifier:@"FirstViewController"];
    fvc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:fvc animated:YES completion:nil];
}

Upvotes: 0

Views: 1721

Answers (2)

Sharanya K M
Sharanya K M

Reputation: 1805

Check whether u have done it in this way

To add view controllers to the tabbarcontroller.

Make sure you have added this in your .h file

@property (nonatomic, strong) UITabBarController *tabController;

In your .m file synthesize tabController and

FirstViewController *fistView = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
SecondViewController *secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
ThirdViewController *thirdView = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];

NSArray *viewControllersArray = [[NSArray alloc] initWithObjects:fistView, secondView, thirdView, nil];

self.tabController = [[UITabBarController alloc] init];
[self.tabController setViewControllers:viewControllersArray animated:YES];

Now the presenting it as modal

[self presentViewController:self.tabController animated:YES completion:nil];

Upvotes: 3

JMarsh
JMarsh

Reputation: 954

If your first view controller is inside the Tab Bar Controller, push the Tab Bar Controller instead.

Upvotes: 1

Related Questions