Re: Programmatic autolayout problem
Re: Programmatic autolayout problem
- Subject: Re: Programmatic autolayout problem
- From: Kyle Sluder <email@hidden>
- Date: Mon, 25 Feb 2013 23:44:50 -0800
On Feb 25, 2013, at 11:34 PM, Rick Mann <email@hidden> wrote:
>
> On Feb 25, 2013, at 23:03 , Kyle Sluder <email@hidden> wrote:
>
>> You must still have an underspecified system of constraints in the
>> horizontal direction. Unfortunately, your description of your constraint
>> system lacks sufficient detail for debugging, which is already difficult
>> to do in textual form.
>>
>> Graphics really are the best. You can use -[NSView
>> constraintsAffectingLayoutForOrientation:] to get an array of all(*) the
>> constraints determining a view's layout in that direction. Pass that
>> array to -[NSWindow visualizeConstraints:] and you get a big pink debug
>> window attached to your own, and all the constraints you passed will be
>> drawn on top of your window. If your layout is ambiguous, there will be
>> an "Exercise Ambiguity" button you can click to help you figure out
>> what's missing.
>
> Sometimes IB puts in a gray width constraint in the NSTextField, and sometimes it gets rid of it. I don't know if that's a fixed width, or if that represents the hugged width of the default text in the field. I have:
>
> |[text1]-1-[text2]-5-|
>
> And it put in a width for text1 but not text2.
You'll never see the constraints created for content hugging or compression resistance.
IB refuses to let your interface be underspecified. If you remove a constraint necessary to fully specify your interface, it will tend to install fixed-size constraints that reflect your views' current frames.
In the nib containing your subviews, is "translates autoresizing mask into constraints" turned off for your root view (that is, the superview of your text fields)? This needs to be on during design time to stifle IB's incredibly annoying behavior of inserting constraints to avoid underspecified interfaces. Right before you insert the subviews into the window's view hierarchy, turn off this property programmatically.
--Kyle Sluder
_______________________________________________
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