1
votes

I try to push to specific view controller from app delegate without losing previously set navigation bar and tab bar items setup.

As presented in my Main storyboard:

storyboard

After 1 action performed in TypeNameVC, on app relaunch I want to skip LogInVC and TypeNameVC in didFinishLaunchingWithOptions in AppDelegate forward to MapViewController or any other VC of Tab Bar Controller.

This code initializes new Navigation Controller with new Navigation Bar and Tab Bar Controller is missing.

UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
//To instantiate Main.storyboard.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
//To instantiate VC to go to.
MapViewController *mapVC = (MapViewController *)[storyboard instantiateViewControllerWithIdentifier:@"MapViewControllerID"];
//To push to instantiated VC.
[navigationController pushViewController:mapVC animated:YES];

I tried to performSegue using segue to Tab Bar Controller but on Navigation Controller stack there is only LoginViewController (I checked it with [navigationController viewControllers])

I read through entire Stack Overflow, I made dozens of combinations but I can't figure out the solution. I would appreciate any help/advice.

UPDATED QUESTION Screen: screen

Have a look to the screen image. First row of screen shows how it looks like if I navigate "normally". Second row shows what happens if I push to MapVC from AppDelegate. What I need is to skip first two VC's with maintaining Navigation and Tab Bar bars setup.

When I navigate "normally" Tab Bar Controller and it's VC's get correctly allocated.

2016-06-08 12:37:44.394 Checkpoint[4196:1034786] Navigation Controller VC's: ( LogInViewController: 0x135d50b00,
TypeNameViewController: 0x135f455b0,
UITabBarController: 0x135f1d180
)
2016-06-08 12:37:44.394 Checkpoint[4196:1034786] Tab Bar Controller VC's: (
MapViewController: 0x137078cf0,
PlacesTableViewController: 0x135f1d7d0,
FriendsTableViewController: 0x137083350
)

When I push directly to MapVC they don't. I do get the point what's going on but I know how to code that solution.

Navigation Controller VC's: (
LogInViewController: 0x15fd5ccf0,
MapViewController: 0x15fd6ffa0
)
2016-06-08 12:31:53.813 Checkpoint[4187:1033755] Tab Bar Controller VC's: (null)

1

1 Answers

0
votes

Customize your class MapViewController for visible Navigation Bar and Tab Bar:

- (instancetype)init
{
    // init code        
    self.hidesBottomBarWhenPushed = NO;
    retur self;
}

-(void)viewWillAppear:(BOOL)animated
{
    // some code
    [self.navigationController setNavigationBarHidden:NO];
}