Re: Auto Layout, NSScrollView and NSStackView - Adding View to StackView
Re: Auto Layout, NSScrollView and NSStackView - Adding View to StackView
- Subject: Re: Auto Layout, NSScrollView and NSStackView - Adding View to StackView
- From: Ken Thomases <email@hidden>
- Date: Mon, 07 Sep 2015 14:57:43 -0500
On Sep 7, 2015, at 2:40 PM, Dave <email@hidden> wrote:
> The ScrollView/StackView combo that myDetailView added to on the addView:inGravity call, is wider than the DetailView. What I’d like to happen is that the Detail is Stretched/Shrunk to match the width of the Scroll View/StackView. I think I need to add a horizontal constraint in code before I added the view. Is this correct?
A stack view always forces its arranged subviews to be completely inside itself. Whether that results in the stack view growing or the arranged subviews shrinking depends on other constraints and/or intrinsic sizes and content-hugging and compression-resistance priorities.
Further, a stack view will try to hug its arranged subviews at the hugging priority set for the given orientation. Again, that may result in the stack view shrinking or the arranged subviews being stretched, depending.
> If so, I’m assuming I need to add the constraint to myDetailView? If so which View do I constrain it to? NSScrollView, the FlippedClipView inside NSScrollView or the StackView or none of the above?
It should not be necessary to add a constraint to the detail view. You should set leading and trailing constraints between the stack view and the clip view so that the stack view is as wide as the clip view.
Other than that, you need to set the horizontal hugging priority of the stack view and then the constraints, content hugging priorities, and compression resistances of the views within the detail view to allow them to adjust themselves to the width.
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden