Re: Automatically resize parent view when subviews resize
Re: Automatically resize parent view when subviews resize
- Subject: Re: Automatically resize parent view when subviews resize
- From: lorenzo <email@hidden>
- Date: Mon, 14 Apr 2014 12:20:10 -0500
On 2014-04-14 09:28, Fritz Anderson wrote:
On 13 Apr 2014, at 11:01 PM, Lorenzo Thurman <email@hidden>
wrote:
I have an NSView with two subviews (A & B) placed horizontally with
respect to each other. The subviews can take a variable number of
uniformly sized subviews. I’ve placed these constraints on subviews A
& B, (all done in IB):
(They should both have the same height)
Top space to container
Bottom space to container
Horizontal spacing between A & B
Intrinsic View -> Placeholder -> Width checked to None
Horizontal content hugging priority set to 1
The left has:
Leading space to container
The right has:
Trailing space to container
The parent view has:
Intrinsic View -> Placeholder -> Width checked to None
Horizontal content hugging priority set to 1
With these constraints, I would expect the parent view to resize
itself horizontally as the subviews (A & B) try to expand to
accomodate the addition of more subviews. But instead, the parent view
does not resize at all, subviews A & B do not resize and their
subviews are crammed together as more are added. If I remove the
Horizontal spacing between A & B, they both resize horizontally, and
if I add enough subviews to each, they extend beyond the right edge of
the parent view.
So, how what mojo do I need to apply to get the parent to resize
horizontally?
I’m really just getting started with Auto layout, and it seems more
confusing than it probably really is or should be.
Thanks
What constraints are you putting on the subviews you add dynamically to
A and B?
— F
The subviews, a subclass of NSView, are made up of three views, a
vertical NSSlider, an NSTextfield rotated 90 degrees and pinned
to the left side of the slider and another textfield pinned to the
bottom of the slider. This subview returns a height of 150.0 and width
of 50 for its inrtinsic size.
The subviews set top/bottom space to container, with 5px between each.
_______________________________________________
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