简体   繁体   English

具有故事板的UITabBarController委托

[英]UITabBarController delegate with storyboard

I know that if i have rootViewController that start with tabBar i can create UITabBar like this: 我知道如果我有以tabBar开头的rootViewController我可以像这样创建UITabBar:

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? 但我的问题是:如果tabBar不是我的rootView,我如何创建tabBar? my app start with login with simple viewController, and after login the tabBar will appear. 我的应用程序以简单的viewController登录开始,登录后将出现tabBar。 Second, where should i create the tab bar, in appDelegate or some else? 其次,我应该在appDelegate或其他地方创建标签栏?

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. 我认为你应该使你的tabBarController成为你的窗口的rootViewController,而不是通过窗口rootViewController模拟地呈现你的loginViewController,登录后你可以解除loginViewController。检查以下代码。

[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. 并在登录后使用委托方法或在loginViewController类中编写以下代码并解除loginViewController。

[self.window.rootViewController dismissModalViewControllerAnimated:YES];

or 要么

    [self dismissModalViewControllerAnimated:YES];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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