Re: Auto-layout: how do I make the other side "win"?
Re: Auto-layout: how do I make the other side "win"?
- Subject: Re: Auto-layout: how do I make the other side "win"?
- From: Quincey Morris <email@hidden>
- Date: Mon, 03 Apr 2017 10:52:13 -0700
On Apr 3, 2017, at 08:57 , Daryle Walker <email@hidden> wrote:
>
> When I select the window in the window controller’s scene in the storyboard, its content size is 800x450. It doesn’t show that way on app run. The view that’s connected to it, a split-view (top & bottom), is still set to the default 450x300. The two splits are also at the default 450x300. The bottom split is a tab-view, whose two tabbed views are also at the default 450x300.
Set the size of the split view to 800 x 450, and change nothing else, then run the app. What size window do you get? What are the relative sizes of the two splits? (Make sure you turn off window restoration, or the results will be meaningless.)
> I haven’t added any constraints yet.
Your content almost certainly won’t lay out correctly when the window is resized by the user at run time.
> It seems that I do have do design from the inside-out and guess the shrunken sizes of my components, instead of having my sizes from the outside-in and having auto-layout shrink the interiors.
In IB you’re designing for *all* window sizes simultaneously, not for a particular size. Auto-layout constraints *are* the design, not the rules for adjusting the design. However, you have two complications:
1. By not having any constraints, you’re leaving it up to IB (or perhaps the run-time constraints system, or perhaps some combination of both) to add constraints (or constraint-like behavior) that attempts to preserve your unconstrained design. You can’t really complain if if doesn’t do what you want, since it doesn’t really know what you want.
2. The size of the outer container (the content view) is unconstrained, because auto-layout is designed to work in both directions (the content view can resize the window; the window can resize the content view). Something has to resolve that ambiguity in each case. Sometimes explicit constraints within the view will do it (and there are specific NSLayoutPriority values which you can use to control the “direction” of the resolution), and sometimes the window size is forced on the content (window restoration, or window drag-to-resize), but if not, the NIB size of the content view sets the size of the window.
_______________________________________________
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