UITabBarController delegate with storyboard
I know that if I have a rootViewController that starts with a tabBar, I can create a UITabBar like this:
UITabBarController *tabController = (UITabBarController *)self.window.rootViewController;
tabController.selectedIndex = [defaults integerForKey:kOptionLastTabSelectedKey];
tabController.delegate = self;
But my problem is, how can I create a tabBar if the tabBar is not my rootView? my app starts by logging in with a simple viewController and after logging in, a tabBar appears. Second, where should I create the tab bar, in appDelegate or something else?
Thanks x
+3
source to share
1 answer
I think you should make your tabBarController for ur rootViewController than your loginViewController versus rootViewController window and after login you can dismiss loginViewController. Check out the following code.
[self.window.rootViewController presentModalViewController:loginViewController animated:YES];
and after using the delegate use method or write the following code in the loginViewController class and leave out the loginViewController.
[self.window.rootViewController dismissModalViewControllerAnimated:YES];
or
[self dismissModalViewControllerAnimated:YES];
0
source to share