iPhoneRecipes 中的 2 个视图控制器如何连接到 tabBarController
我正在通过查看 iPhone Recipes 示例应用程序来学习 iPhone 编程。
我对两个视图控制器如何连接到选项卡栏感到困惑。 如果它们在 XIB 中连接,任何人都可以解释它是如何完成的,或者我可以在哪里获得有关 XIB 中连接事物的更多视觉辅助细节。
这是我学习过程中的出发点:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
recipeListController.managedObjectContext = self.managedObjectContext;
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
}
I am learning iPhone programming by reviewing the iPhone Recipes sample application.
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];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,选项卡栏的视图属性被添加为窗口的子视图。
选项卡栏的视图属性指向选项卡栏的可视组件(选项卡栏视图本身),选项卡栏控制器处理其行为(更改选项卡等)。
每个单独的选项卡都是选项卡栏的子视图,因此当将选项卡栏视图添加为窗口的子视图时,它的子视图也会随之而来。 一开始你的头脑有点棘手,但在你更多地使用界面构建器之后应该会开始理解。
XIB 中发生的所有事情就是您在每个选项卡上设置视图出口,以便在选择每个选项卡时可以显示它们。
希望这可以帮助。
Basically, the view property of the tab bar is being added as a subview of the window.
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.
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.
Hope this helps.