0
votes

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.

3

3 Answers

0
votes

You should implement this through the storyboard only.

I tried sample project using appcoda.I run it successfully that.I show you the storyboard design.

enter image description here

enter image description here

It has implemented using multiple view controllers.

0
votes
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];
0
votes

I thought this might be helpful for all you swift'ers. I have a project setup similarly, LoginViewcontroller -> TabBarController (5 tabs) -> NavigationController for each tab -> Other ViewControllers

In storyboard, I gave my TabBarController a storyboard ID

Within AppDelegate(didFinishLaunchingWithOptions) I added

self.window = UIWindow(frame: UIScreen.main.bounds)
let storyboard = UIStoryboard.init(name: "Main", bundle: nil)
let viewController = storyboard.instantiateViewController(withIdentifier: "TabBarControllerID") as! UITabBarController
viewController.selectedIndex = 3
self.window?.rootViewController = viewController
self.window?.makeKeyAndVisible()

Change selectedIndex value to whatever tab you need