This is the first time I'm trying to programmatically use autolayout, and I 
can't seem to do a simple thing.

I'm creating a bunch of views using an NSViewController subclass for each, and 
adding them to a window (the window created from the default Cocoa App 
template).

I programmatically build a view layout string that looks like this:

        |[view0][view1]

as well as individual constraints that look like:

        V:|[view]

That is, I just want my views to stack left-to-right (ideally, right-to-left on 
RTL systems), with no space between them. Prior to this, I resize the window to 
be just big enough for all the views.

Inside each view are a couple of NSTextFields, laid out in IB. What I want to 
do in IB is something like:

        |-5-[text1]-5-[text2]-5-|

And have the parent view compress all the way down to that, such that the text 
is never truncated. But what I'm ending up with are these frames:

containing view: {{0, 20}, {93, 0}}
text1: {{2, -17}, {34, 17}}
text2: {{35, -17}, {56, 17}}

Note that the containing view height is 0, and the y-coordinate for the labels 
is -17; so, nothing's visible.

Prior to auto layout, it looks like:

containing view: {{0, 0}, {95, 20}}
text1: {{2, 3}, {34, 17}}
text2: {{35, 3}, {58, 17}}

Which is how it's laid out in IB.

Can anyone please tell me how to set up the constraints in IB so that the view 
is as small as it can be, without truncating text or going to 0?

A separate question: Is it possible to get the window to expand to just hug the 
stacked views?

-- 
Rick




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to