The doc for stackViewWithViews: says it’s a horizontal layout and they’re added 
to the “view’s leading gravity area” - if I were writing that I’d use the 
constant name, it’s easy to overlook. It doesn’t mention it, but if it’s 
vertical they go in Top.

If you just want your views to show up in the order they’re added, pick any one 
of the gravities - I use Top/Leading - and always use that.

If you’ve got something like my app's Settings which has a layout similar to 
System Prefs, but with just a top section, a bottom section, and an optional 
middle section that can have multiple row-groups, the top section goes in Top, 
bottom in Bottom, and middle ones go in Center, and I don’t have to worry about 
what order I do the adding.

Or if you have one view that should always be the top - say, it’s a summary - 
and others that can go in any order, put the summary in Top, the others in 
Bottom or Center.

(I’ve become a *major* fan of StackView recently.)

On Aug 28, 2015, at 6:18 AM, Dave <[email protected]> wrote:

> Hi,
> 
> I’m looking at:
> 
> https://urldefense.proofpoint.com/v2/url?u=https-3A__developer.apple.com_library_mac_documentation_AppKit_Reference_NSStackView-5FClass_-23__apple-5Fref_occ_clm_NSStackView_stackViewWithViews-3A&d=BQIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=ie7S-J__EKnfyVOBV7-jV2rZ--p47O6vkyTklpDM3h4&m=FTCRaGVYapFRJSeyN676LOwzL9dI1Fa7Rcb81M6vJic&s=SJ2ra9SmJCzKbCDlHMBg6I-eb19RtMb4QJWImBK3ZEE&e=
>  
> 
> and wondering if there is any better documentation available for NSStackView? 
> 
> It talks about "Gravity Areas" and I’m confused as to how they should be 
> used. I basically want a StackView similar to the InfoBarView sample in that 
> sample, it creates a Stack View like this:
> 
> NSStackView *stackView = [NSStackView stackViewWithViews:@[
>                                                                   self.header,
>                                                                  
> self.shapeDisclosureViewController.view,
>                                                                  
> self.imagePickerDisclosureViewController.view,
>                                                                  
> self.otherDisclosureViewController.view]];
> 
>  // we want our views arranged from top to bottom
>  stackView.orientation = NSUserInterfaceLayoutOrientationVertical;
> 
>  // the internal views should be aligned with their centers
>  // (although since they'll all be the same width, it won't end up mattering)
>  //
>  stackView.alignment = NSLayoutAttributeCenterX;
> 
>  stackView.spacing = 0; // No spacing between the disclosure views
> 
>  // have the stackView strongly hug the sides of the views it contains
>  [stackView setHuggingPriority:NSLayoutPriorityDefaultHigh 
> forOrientation:NSLayoutConstraintOrientationHorizontal];
> 
>  // have the stackView grow and shrink as its internal views grow, are added, 
> or are removed
>  [stackView setHuggingPriority:NSLayoutPriorityDefaultHigh 
> forOrientation:NSLayoutConstraintOrientationVertical];
> 
>  self.window.contentView = stackView;
> 
> In this case, which Gravity ares are the views added to?
> 
> In my code, I want to add new views to the Stack View using addView: 
> inGravity: so to get the same results as the above, which Gravity do I 
> specify?
> 
> Thanks in advance for any help.
> 
> All the Best
> Dave
> 
> 
> 
> 
> 
> 
> _______________________________________________
> 
> Cocoa-dev mailing list ([email protected])
> 
> 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/lrucker%40vmware.com
> 
> This email sent to [email protected]


_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to