objective c - Autolayout of View Controller View in a Container -


i have nswindow has 2 container views within it, in 1 xib, so:

screenshot 1

in xib, have view sidebar, managed different view controller, so:

screenshot 2

when add subview container view, this:

self.sidebarviewcontroller.view.frame = self.sidebarcontainer.bounds; [self.sidebarcontainer addsubview:self.sidebarviewcontroller.view]; 

when build , run, , resize window, happens:

screenshot 3

the container tracks height of it's superview properly, sidebar view not track height of container.

how can set things height of sidebarvcs' view tracks height of container window resized?


i think i've solved so:

[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 yet understand why autoresizemask layout constraint doesn't automatically, think i'm closer understanding relationships between views here.

use nsboxes containers. in sidebar, add nsbox inside nsview , constrain sides view. when want swap in view side bar can call container (the nsbox object) setcontentview:.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -