views:

24

answers:

1

Is it true that UITabBarController never calls initWithNibName on its child views (individual tabs)? Or have I just set my app up in a really screwed-up way?

My MainWindow.xib looks like this in interface builder: tab bar in interface builder

Note that the Window is completely blank while all the action happens in the Tab Bar Controller.

My app delegate calls [window addSubview:tabBarController.view] in application:didFinishLaunchingWithOptions and once that happens we're off to the races!

But when I put breakpoints on the init, initWithNibName:, and initWithNibName:bundle: methods in any of my individual controllers (which are listed in Interface Builder as children of the tabs, as the image above shows), nothing catches.

Thanks in advance!

+1  A: 

It doesn't call initWithNibName:, they call initWithCoder: -- initWithNibName: is only called when you programmatically instantiate a class and hand it a xib file to define its subviews from.

(Updated: I remembered wrong, initWithNibName: is never called unless one makes the call oneself.)

Kalle
aha. `initWithCoder` indeed catches. By the way, my child views *are* defined in nibs (e.g. some of the elements never get initialized in code, only by the device reading the associated nib file). So that means `initWithNibName:` only gets called for top-level type things?
unsorted
Yes, and actually my answer is incorrect -- they all get `initWithCoder:` -- will update in a sec.
Kalle
oh, okay. that makes sense--thanks!
unsorted