0
votes

How can I call TabbarViewControllers connected viewController from simple UIViewController where simple UIViewController is embedded in UINavigationController. I want same Push and Pop effect which UINavigationController provide when moving one to other viewController. After digging in google I find out that pushing tab bar view controller inside navigation stack is not a good way to structure app. I tried creating custom transaction animation but it's not same like UINavigation transaction effect. Please give some suggestion or solution. Thanks!!

2
Mean you need to open UITabbarController from normal view controller, right?Nirmalsinh
yes @Nirmalsinh.jay patel

2 Answers

1
votes

You can directly set UITabbarController to window's rootViewController.

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
_tabObj = (TabbarViewController*) [storyboard instantiateViewControllerWithIdentifier:@"TabbarViewController"];
self.window.rootViewController = _tabObj;

Check above code.

0
votes

as Nirmalsinh's answer, you could set view controller that conform UITabBarControllerDelegate as your self.window.rootViewController, then should have UITabBarController inside it.

var tabBarController: UITabBarController

then you can each of tab's navigation and view controller

let firstViewController = FirstViewController()
let firstNavigationController = UINavigationController(rootViewController: firstViewController)
// other setter

tabBarController.viewControllers = [
    firstNavigationController
]

then inside FirstViewController, you can call

let secondViewController = SecondViewController()
navigationController?.pushViewController(SecondViewController, animated: true)