I have a root UINavigationController
and want to init it with an instance of UITabBarController
, something like this:
TabBarController * viewController = [[TabBarController alloc] init];
UINavigationController navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
As per the documentation for initWithRootViewController:
method, this is a bad idea:
The view controller that resides at the bottom of the navigation stack. This object cannot be an instance of the UITabBarController class.
So I wonder:
- Why do we have such a restriction?
- ...why does it work and doesn't throw any exceptions? Are there any side effects of such approach? I'm trying to reuse the single navigation controller across all tabs of my tab bar controller and so far the code from above works quite well.
What I need is to 1) have a consistent NavBar in all of my tabs (but with different titles and left/right icons 2) Some tabs must support drill-down navigation 3) I don't need the tab bar panel when switching to deeper elements of the screens hierarchy.
EDIT
I've just realized that Skype for iOS is a good example of what I am trying to achieve: it works exactly like my app in terms of tabs and navigation.