2个视图控制器如何连接到iPhoneRecipes中的tabBarController [英] How are the 2 View Controllers wired to the tabBarController in iPhoneRecipes

查看:53
本文介绍了2个视图控制器如何连接到iPhoneRecipes中的tabBarController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过查看iPhone Recipes示例应用程序来学习iPhone编程.

I am learning iPhone programming by reviewing the iPhone Recipes sample application.

我对如何将两个视图控制器连接到选项卡栏感到困惑.如果它们连接在XIB中,那么谁能解释一下它是如何完成的,或者在哪里可以得到有关XIB中连接事物的更多直观帮助细节.

I am puzzled with how the two view controllers are wired to the tab bar. If they are wired in the XIB, can anyone explain how it is done or where I can get more visually aided details on connecting things in the XIBs.

这是我学习过程的起点:

This is my starting point in the learning process:

- (void)applicationDidFinishLaunching:(UIApplication *)application {
 recipeListController.managedObjectContext = self.managedObjectContext;
 [window addSubview:tabBarController.view];
 [window makeKeyAndVisible];
}

推荐答案

基本上,选项卡栏的view属性被添加为窗口的子视图.

Basically, the view property of the tab bar is being added as a subview of the window.

选项卡栏的view属性指向选项卡栏的可视组件(选项卡栏视图本身),并且选项卡栏控制器处理其行为(更改选项卡等).

The view property of the tab bar points at the tab bar's visual component, (the tab bar view itself) and the tab bar controller handles its behaviour (changing tabs, etc).

每个单独的选项卡都是选项卡栏的子视图,因此,当将选项卡栏视图添加为窗口的子视图时,它的子视图也随处可见.刚开始时会有点棘手,但是在与界面生成器一起玩了更多之后,它应该会开始陷入.

Each individual tab is a subview of the tab bar, so when the tab bar view is added as a subview of the window, its subviews are brought along for the ride. It's a little tricky to get your head around at first, but it should start sinking in after youplay around with interface builder a bit more.

在XIB中发生的所有事情就是您在每个选项卡上设置了视图插座,以便在选择每个选项卡时可以显示它们.

All that's happening in the XIB is you're setting the view outlets on each tab so that they can be displayed when each tab is selected.

希望这会有所帮助.

这篇关于2个视图控制器如何连接到iPhoneRecipes中的tabBarController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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