Okay, here’s a dumb question… How do you make a stack view actually stack things? When I add subviews into a stack view, instead of appearing one after another as I expect, they’re all laid on top of one another.
I created a sample program with one window filled with a scroll view, and inside that a stack view. My Document class just throws in a bunch of subviews (quickies made with NSBox), and no matter what layout alignment I choose, they appear overlaid on one another. Here’s the bit of code that matters: @interface Document () @property (weak) IBOutlet NSStackView* theStack; @property NSArray* heightArray; @end @implementation Document - (instancetype)init { self = [super init]; if (self) { self.heightArray = @[ @50, @70, @25, @90, @25, @150, @50, @200, @30, @75, @25, @90, @150, @300, @80, @50 ]; } return self; } - (void)windowControllerDidLoadNib:(NSWindowController *)aController { [super windowControllerDidLoadNib:aController]; // Add any code here that needs to be executed once the windowController has loaded the document's window. self.theStack.alignment = NSLayoutAttributeBottom; unsigned long count = [self.heightArray count]; for ( unsigned long ix = 0; ix < count; ++ix ) { NSRect rect = CGRectMake(0, 0, 75, [[self.heightArray objectAtIndex: ix] doubleValue] ); NSBox* box = [[NSBox alloc] initWithFrame: rect]; box.fillColor = [NSColor blueColor]; box.borderType = NSLineBorder; box.borderWidth = 20; box.borderColor = [NSColor magentaColor]; box.titlePosition = NSNoTitle; [self.theStack insertView:box atIndex:ix inGravity:NSStackViewGravityCenter]; } } — Charles Jenkins _______________________________________________ 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