I have an NSWindow in which there are 2 types of container, all in one xib, for example:

In another xib, I have a sidebar view controlled by another view controller, for example:

When I add a subview to the container view, I do it like this:
self.sidebarViewController.view.frame = self.sidebarContainer.bounds; [self.sidebarContainer addSubview:self.sidebarViewController.view];
When I create and start and resize this window, this happens:

The container correctly tracks the height of the add-in, but the sidebar view itself does not track the height of the container.
How can I adjust things so that the viewing height of sidebarVCs tracks the height of the container when the window is resized?
I think I solved it like this:
[self.sidebarViewController.view setTranslatesAutoresizingMaskIntoConstraints:NO]; NSLayoutConstraint *w = [NSLayoutConstraint constraintWithItem:self.sidebarViewController.view attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 constant:150.0]; NSArray *c1 = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[view]|" options:0 metrics:nil views:@{ @"view":self.sidebarViewController.view }]; [self.sidebarContainer addConstraints:c1]; [self.sidebarContainer addConstraint:w];
I still don't understand why the autoresizemask layout constraint doesn't do this automatically, but I think I'm closer to understanding the relationship between the views here.
source share