具有故事板的UITabBarController委托

时间:2012-03-10 19:41:51

标签: ios ios5 uitabbarcontroller storyboard

我知道如果我有以tabBar开头的rootViewController我可以像这样创建UITabBar:

UITabBarController *tabController = (UITabBarController *)self.window.rootViewController;
tabController.selectedIndex = [defaults integerForKey:kOptionLastTabSelectedKey];
tabController.delegate = self;

但我的问题是:如果tabBar不是我的rootView,我如何创建tabBar?我的应用程序以简单的viewController登录开始,登录后将出现tabBar。 其次,我应该在appDelegate或其他地方创建标签栏?

感谢的!!!

1 个答案:

答案 0 :(得分:0)

我认为你应该让你的tabBarController成为你的窗口的rootViewController,而不是通过窗口rootViewController以模态方式呈现你的loginViewController,登录后你可以解除loginViewController。请检查以下代码。

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

并在登录后使用委托方法或在loginViewController类中编写以下代码并解除loginViewController。

[self.window.rootViewController dismissModalViewControllerAnimated:YES];

    [self dismissModalViewControllerAnimated:YES];