Hi Tom,

I think the problem here is that if you have view A containing textField,
and textField is centered in A, there's no constraint expressing anything
about A's height. A can go to zero height and still have the textField
centered within it.

If you added something giving a height (or fastened the edges of A to the
textField), that'd probably do it.

-ken

On Fri, Nov 8, 2013 at 5:02 PM, Tom Harrington <atomicb...@gmail.com> wrote:

> I'm trying to use NSStackView in what should be the most basic way
> possible. I create the stack view and add two subviews. But only one of
> them is ever visible.
>
> I'm creating the stack view in code (in my app delegate, for purposes of a
> test project):
>
>     NSStackView *stackView = [NSStackView stackViewWithViews:@
> [self.subview1,
> self.subview2]];
>
>     stackView.orientation = NSUserInterfaceLayoutOrientationVertical;
>
>     stackView.alignment = NSLayoutAttributeCenterX;
>
>     stackView.spacing = 0;
>
>     [self.window.contentView addSubview:stackView];
>
>     [self.window.contentView addConstraints:[NSLayoutConstraint
> constraintsWithVisualFormat:@"H:|-(50)-[stackView]-(50)-|"
>
>
>         options:0
>
>
>         metrics:nil
>
>
>           views:NSDictionaryOfVariableBindings(stackView)]];
>
>     [self.window.contentView addConstraints:[NSLayoutConstraint
> constraintsWithVisualFormat:@"V:|-(50)-[stackView]-(50)-|"
>
>
>         options:0
>
>
>         metrics:nil
>
>
>           views:NSDictionaryOfVariableBindings(stackView)]];
>
> The two subviews subview1 and subview2 are just plain NSViews, each with an
> NSTextField label subview constrained to be in the center.
>
> At run time, only one subview is visible-- the last one in the array. It's
> resized to fill the entire stack view. If I resize the window, the stack
> view and the one visible subview also resize, but no window size ever gets
> both subviews showing.
>
> Obviously I'm missing something basic about stack views, but I don't know
> what. I've been looking at Apple's InfoBarStackView demo app but haven't
> worked out which detail it has that I don't (Apple's demo:
>
> https://developer.apple.com/library/mac/samplecode/InfoBarStackView/Introduction/Intro.html
> )
>
> --
> Tom Harrington
> atomicb...@gmail.com
> AIM: atomicbird1
> _______________________________________________
>
> 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/kenferry%40gmail.com
>
> This email sent to kenfe...@gmail.com
_______________________________________________

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

Reply via email to