In real apps the view hierarchy can be complex at it really helps to be able to put different views in different nibs. I am following InfoBarStackView example project they give a really nice example of how to use the new NSStackView class which hosts different views. They make a DisclosureViewController
which is responsible for hosting a content view
changing the it's size so that is can go from a open to closed state.
Here is a simplified example. What we have are two separate nibs:
DisclosureViewController
ContentViewController
What is the simplest way to load the content view inside the placeholder view of the disclosure view? Is it possible to do this only in IB only?
Currently my AppDelegate has a lot of redundancy because it need to hold references to both view controllers. I wondering if there is a way of simplifying the situation? For this simple example, the AppDelegate would load from the two different nibs using code like this,
// In AppDelegate.m
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
[_disclosureView1.view replaceSubview:_disclosureView1.placeholder with:_contentView1.view];
[(NSView*)_window.contentView addSubview:_disclosureView1.view];
}