Loading an external NIB, how do I set the view property?
If I am loadi开发者_高级运维ng a view from another NIB, how do I set the File's Owner view property? IB is not letting me hook it up to my View Controller which is loading the external NIB.
My NIB looks like this:
File's Owner - Identity is set to LBRootViewController
First Responder
LBTableViewController - Identity is set to LBTableViewController, NIB Name is LBTableViewController
You can't set the File Owner to a view controller defined in another nib because you can't set outlets across nibs. Each view controller has to be the File Owner of its own nib.
No nib should have two controllers that are active at one time. The setup where you have a root controller in a nav does not actually have two controllers but instead causes the root controller to load the second controller nib at runtime.
It looks like you should have two nibs here: LBRootViewController.xib
and LBTableViewController.xib
. The File Owner of each nib is an instance of the classes the nibs are named for. You can create an outlet in the LBRootViewController class that points to an instance of LBTableViewController. When LBRootViewController.xib
loads it does not trigger the loading of LBTableViewController.xib
until the attribute serving as the outlet is accessed.
Select the File's Owner proxy (in the NIB window) and switch to the identity tab in the inspector palette (the far-right tab with the circle-i icon). Set the Class field to NSViewController
(or whatever your view controller subclass is, if any). You should now be able to drag your outlet!
精彩评论