故事板 - UITabBarController [英] Storyboard - UITabBarController

查看:221
本文介绍了故事板 - UITabBarController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我正在玩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来查看表是否为空它是否选择了第二个viewcontroller(tabbar项目2),如果没有则选择第一个viewcontroller(tabbar项目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!

谢谢!

推荐答案

你的app delegate将拥有一个窗口属性。这可以用来获取指向故事板的初始视图控制器(它将是你的UITabBarController)的指针,就像我的一个app代理应用程序中的这个例子: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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆