問題描述
我今天正在玩 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模板網!