简体   繁体   中英

UITabBarController delegate with storyboard

I know that if i have rootViewController that start with tabBar i can create 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 tabBar if the tabBar is not my rootView? my app start with login with simple viewController, and after login the tabBar will appear. Second, where should i create the tab bar, in appDelegate or some else?

Thank's!!!

I think you should make your tabBarController to be rootViewController to ur window than present your loginViewController modally over window rootViewController and after login you can dismiss loginViewController .Check the following code.

[self.window.rootViewController presentModalViewController:loginViewController animated:YES];

and after the login use delegate method or write following code in the loginViewController class and dismiss loginViewController.

[self.window.rootViewController dismissModalViewControllerAnimated:YES];

or

    [self dismissModalViewControllerAnimated:YES];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM