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.
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!
Thanks!
A container view controller that manages a multiselection interface, where the selection determines which child view controller to display.
Adding a Tab Bar Controller with View Controllers. The Interface Builder is an easy way to implement a Tab Bar Controller. Open Main. storyboard in the Interface Builder. Drag a Tab Bar Controller from the Object Library to the UI Preview pane.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With