Note that there are some explanatory texts on larger screens.

plurals
  1. PONSViewController and multiple subviews from a Nib
    primarykey
    data
    text
    <p>I'm having a difficult time wrapping my head around loading views with Interface Builder and NSViewController.</p> <p>My goal is to have a view which meets the following description: Top bar at the top (like a toolbar but not exactly) which spans the entire width of the view, and a second "content view" below. This composite view is owned by my <code>NSViewController</code> subclass.</p> <p>It made sense to use Interface Builder for this. I have created a view nib, and added to it two subviews, laid them out properly (with the top bar and the content view). I've set <code>File's Owner</code> to be <code>MyViewController</code>, and connected outlets and such.</p> <p>The views I wish to load in (the bar and the content) are also in their own nibs (this might be what's tripping me up) and those nibs have their Custom Class set to the respective NSView subclass where applicable. I'm not sure what to set as their <code>File's Owner</code> (I'm guessing <code>MyController</code> as it should be their owner).</p> <p>Alas, when I init an instance of <code>MyViewController</code> none of my nibs actually display. I've added it to my Window's contentView properly (I've checked otherwise), and actually, things sort of load. That is, <code>awakeFromNib</code> gets sent to the bar view, but it does not display in the window. I think I've definitely got some wires crossed somewhere. Perhaps someone could lend a hand to relieve some of my frustration?</p> <p><strong>EDIT</strong> some code to show what I'm doing</p> <p>The controller is loaded when my application finishes launching, from the app delegate:</p> <pre><code>MyController *controller = [[MyController alloc] initWithNibName:@"MyController" bundle:nil]; [window setContentView:[controller view]]; </code></pre> <p>And then in my initWithNibName I don't do anything but call to super for now. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload