• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Programmatic autolayout problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Programmatic autolayout problem


  • Subject: Programmatic autolayout problem
  • From: Rick Mann <email@hidden>
  • Date: Mon, 25 Feb 2013 20:33:49 -0800

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 (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

  • Follow-Ups:
    • Re: Programmatic autolayout problem
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: [OT] Sync vs ASync Server Comms
  • Next by Date: Re: Programmatic autolayout problem
  • Previous by thread: Re: Documents not opening from Finder
  • Next by thread: Re: Programmatic autolayout problem
  • Index(es):
    • Date
    • Thread