title: Cocoa Autolayout and Resizing of Subviews
body: <p>I am having troubles getting my subviews to resize correctly using Autolayout. To illustrate my point, I put together a minimalistic example.</p>
  
  <p>First I created a new NSViewController and added a subview to it (in this particular case an NSTextView) and added Autolayout constraints.</p>
  
  <p><img src="https://i.stack.imgur.com/rUQlJ.png" alt="enter image description here"></p>
  
  <p>I then added a custom view to my MainMenu.xib and set up Autolayout constraints for that too.</p>
  
  <p><img src="https://i.stack.imgur.com/1TMd3.png" alt="enter image description here"></p>
  
  <p>Finally, I created an instance of my view controller and put its view inside my custom view.</p>
  
  <pre><code>#import "AppDelegate.h"
  #import "MyViewController.h"
  
  @interface AppDelegate()
  @property (weak) IBOutlet NSView *customView;
  @end
  
  @implementation AppDelegate
  
  - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
  {
      MyViewController *myViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
  
      [self.customView addSubview:myViewController.view];
      myViewController.view.frame = self.customView.bounds;
  }
  
  @end
  </code></pre>
  
  <p>Since "Autoresizes Subviews" is checked in both xib files, I would expect the NSTextView to resize when I resize the main window. However, it just stays in place.</p>
  
  <p><img src="https://i.stack.imgur.com/Q9q0O.png" alt="enter image description here"></p>
  
  <p>What am I missing here? This has puzzled me for a few days now.</p>
  
  <p>Thanks,
  Michael Knudsen</p>