Search code examples
objective-cuinavigationcontrolleruitabbarcontrollerappdelegatepresentviewcontroller

How to present view controller from Appdelegate via TabBarController => NavbarController


How i can present view controller with all stack from appdelegate.
TabBarContoller is the rootviewcontoller.
I have 4 tabs on TabBarController and each of them are nav controllers.
So i need to present viewcontroller like this. tabBar => navBar => mainViewContoller => aViewController => bViewController;
And i should be able to use to navigate back to the mainviewcontroller or navigate by tabbar.

I have a storyboard .

I tried a lot of solutions which were recommended by similar questions but it didn't help.


Solution

  • TabBarController * tabBar = (TabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
                       if([tabBar isKindOfClass:[UITabBarController class]]){
                       [tabBar setSelectedIndex:0];
                       UINavigationController * navBar = (UINavigationController *)tabBar.selectedViewController;
                       UIViewController * currentVC = navBar.topViewController;
                       [currentVC performSegueWithIdentifier:@"notificationSegue" sender:nil];