Yes, I could add child views to the NSSplitView which is already in the MainWindowController nib. In fact, I did that to start with and that eliminates the autolayout issue. With that implementation, I setup the autolayout in IB, just as you suggested, then instantiated A and B and added them as children to the views that already existed. And it works fine, of course. The reason I chose to not do it that way is to remove those extra unused views for efficiency. This is (getting to be) a rather complex app and I wanted to avoid having extra views lying around that don't really do anything.
All that aside, I think my initial assumption was incorrect. The problem I thought I was going to run into is essentially this: SplitView is loaded from its nib and MainWindowController.viewDidLoad gets called. In viewDidLoad, I do a = [[A alloc] initWithNibName:]; b = [[B alloc] initWithNibName:]; I thought that when [[alloc] initWithNibName] returned, it was not guaranteed that those nibs would be loaded yet and so the views in them wouldn't be guaranteed to exist yet. If that were true, there would be no A.view or B.view to add to the SplitView or do autolayout with.
Last night, I went ahead and implemented it anyway assuming that the nib would be loaded and the view would exist after the return of [alloc] initWithNibName:] and it works fine. I think I incorrectly inferred A.view and B.view wouldn't be guaranteed to exist yet, because of the existence of viewDidLoad.
Or, was my initial assumption correct and I'm just getting lucky that A.view and B.view happen to exist immediately up return from [alloc] initWithNibName:]?
Topic:
UI Frameworks
SubTopic:
AppKit
Tags: