> On 23 Nov 2014, at 16:48, SevenBits <sevenbitst...@gmail.com> wrote: > > Hello Cocoaphiles, ;) > > I've just started experimenting with NSStackView, 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 NSStackViewdocumentation, and can't seem to > find anything. > > From what I understand, the intrinsic content size should prohibit the view > from getting shrunk this small. I'm not too familiar with NSStackView, so any > help would be appreciated. > I think you will find that NSScrollView -intrinsicContentSize will return {NSViewNoIntrinsicMetric, NSViewNoIntrinsicMetric}. i.e: a scroll view doesn’t report an intrinsic content size.
NSStackView calls -fittingSize to determine the size for its subviews. If you add a subview to a vertical NSStackView without a fully constrained height it collapses to zero - ish. Often, if you ask XCode to add contains to your view it will not fully constrain the height of the view. This cases them to misbehave in an NSStackView. So the point is add some constraints! NSStackView is supremely useful once you get your head around the constraint basics. - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSLog(@"- intrinsicContentSize : %@", NSStringFromSize(self.textScrollView1.intrinsicContentSize)); NSLog(@"- fitting size: %@", NSStringFromSize(self.textScrollView1.fittingSize)); self.textScrollView1.translatesAutoresizingMaskIntoConstraints = NO; self.textScrollView2.translatesAutoresizingMaskIntoConstraints = NO; self.stackView.alignment = NSLayoutAttributeWidth; [self.stackView addView:self.textScrollView1 inGravity:NSStackViewGravityTop]; [self.stackView addView:self.textScrollView2 inGravity:NSStackViewGravityTop]; NSDictionary *views = NSDictionaryOfVariableBindings(_textScrollView1, _textScrollView2); [self.stackView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[_textScrollView1(==_textScrollView2)]" options:0 metrics:nil views:views]]; } I use the following with view -hidden bindings to manipulate complex view stacks https://github.com/mugginsoft/TSStackView Jonathan _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com