title: NSStackView does not layout views properly
body: <p>I've just started experimenting with <code>NSStackView</code>, and I'm having a very interesting problem which I can't solve. I've scoured the auto layout guides on Apple's website as well as the <code>NSStackView</code> documentation, and can't seem to find anything.</p>
  
  <p>My problem is that I have two identical <code>NSScrollView</code> objects (each with an embedded <code>NSTextView</code>) which are loaded from nib files. When I add these views to my stack view, the one that is added first takes up 100% of the available space, and the second collapses completely down to the bottom with a height of 2 pixels while taking up all available horizontal space. In effect, this looks like the first view is the only one in the window. Here's what it currently looks like:</p>
  
  <p><img src="https://i.stack.imgur.com/2tEwm.png" alt="A screenshot of the problematic window"></p>
  
  <p>It's nearly impossible to see in this example because of the background color, but the scroll view ends a couple pixels above the bottom of the window. Here's a better view from the view hierarchy inspector, where I have this 2 pixel high view selected (<a href="https://i.stack.imgur.com/XJeG5.png" rel="nofollow noreferrer">click here to view larger</a>):</p>
  
  <p><img src="https://i.stack.imgur.com/XJeG5.png" alt="The Xcode view hierarchy inspector"></p>
  
  <p>Here's the relevant setup code:</p>
  
  <pre><code>// Load the stack view
  self.inputViewController = [[NSViewController alloc] initWithNibName:@"Document_TextInputView" bundle:nil];
  self.textView = (NSTextView *)[[(NSScrollView *)self.inputViewController.view contentView] documentView];
  
  self.outputViewController = [[NSViewController alloc] initWithNibName:@"Document_TextOutputView" bundle:nil];
  self.outputView = (NSTextView *)[[(NSScrollView *)self.outputViewController.view contentView] documentView];
  
  // Add all views into the stack view
  [self.stackView addView:self.inputViewController.view inGravity:NSStackViewGravityTop];
  [self.stackView addView:self.outputViewController.view inGravity:NSStackViewGravityBottom];
  self.stackView.orientation = NSUserInterfaceLayoutOrientationVertical;
  
  // Load the text into the window.
  [self.textView setString:self.cachedText];
  [self.outputView setString:@"=== PROGRAM OUTPUT ===\n"];
  [self.codeActionSegmentedControl setEnabled:NO forSegment:1];
  </code></pre>
  
  <p>From what I understand, the intrinsic content size <em>should</em> prohibit the view from getting shrunk this small. I'm not too familiar with <code>NSStackView</code>, so any help would be appreciated.</p>