我今天正在玩 iOS 5 和故事板.我目前拥有它,以便主要故事板以 uitabbarcontroller 开始,然后是 navigationviewcontroler,最后是 uiviewcontroller.一切正常.
I was playing around with iOS 5 and storyboards today. I currently have it so that the main storyboards starts with a uitabbarcontroller then a navigationviewcontroler and finally a uiviewcontroller. All that works fine.
我正在寻找的是如何在应用程序启动时动态设置 uitabbarcontroller 正在显示的 viewconotroller.所以我想使用 CoreData 来查看一个表是否为空,它是选择第二个视图控制器(标签栏项目 2),如果没有选择第一个视图控制器(标签栏项目 1).
What I'm looking for is how to dynamically set which viewconotroller the uitabbarcontroller is displaying when the application starts. So I'd want to use CoreData to see if a table was empty and it it was select the second viewcontroller (tabbar item 2) and if not select the first viewcontroller (tabbar item 1).
由于故事板正在处理正在显示的内容,我不确定如何在应用程序委托中进行设置?
Since the storyboard is handling what is being displayed, I wasn't sure how in the app delegate I could set this?
希望有人可以在这里为我指明正确的方向!
Hoping someone can point me in the right direction here!
谢谢!
您的应用程序委托将有一个窗口属性.这可用于获取指向情节提要的初始视图控制器(将是您的 UITabBarController)的指针,例如来自我的应用程序委托应用程序之一的此示例:didFinishLaunchingWithOptions:
Your app delegate will have a window property. That can be used to get a pointer to the storyboard's initial view controller (which will be your UITabBarController), like this example from one of my app delegates application:didFinishLaunchingWithOptions:
UITabBarController *tabController =
(UITabBarController *)self.window.rootViewController;
tabController.selectedIndex =
[defaults integerForKey:kOptionLastTabSelectedKey];
tabController.delegate = self;
这篇关于故事板 - UITabBarController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!