views:

231

answers:

1

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];
}
+1  A: 

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.

Jasarien