Auto Layout & Stacked NSTextViews

  • I have a layout problem that I would think auto layout was designed to solve but I can't seem to get it to work. In short, I have three NSTextViews aligned vertically (with NSTextField labels between them) and I want them all to grow vertically but keep the space between them. The best I can get is to grow the bottom one, but the two above don't want to budge. Is there a trick to getting this to work, or is auto layout just not up to the task?

    TIA,

    Keary Suska
    Esoteritech, Inc.
    "Demystifying technology for your home or business"
  • On 26 May 2013, at 12:31 PM, Keary Suska <xcode-users...> wrote:

    > I have a layout problem that I would think auto layout was designed to solve but I can't seem to get it to work. In short, I have three NSTextViews aligned vertically (with NSTextField labels between them) and I want them all to grow vertically but keep the space between them. The best I can get is to grow the bottom one, but the two above don't want to budge. Is there a trick to getting this to work, or is auto layout just not up to the task?

    My quick experiment says:

    A    top fixed to top of container
    B    top fixed to bottom of A; height == height of A
    C    top fixed to the bottom of B; height == height of B; bottom fixed to bottom of container.

    Delete all other vertical constraints; the above appears to be sufficient and consistent, so IB won't fight you. The Cocoa layout instrument doesn't see anything wrong.

    That's what I found in about three minutes. It worked for me.

    --
    Fritz Anderson
    Xcode 4 Unleashed: 4.5 supplement for free!
    http://www.informit.com/store/xcode-4-unleashed-9780672333279
  • On May 26, 2013, at 1:26 PM, Fritz Anderson wrote:

    > On 26 May 2013, at 12:31 PM, Keary Suska <xcode-users...> wrote:
    >
    >> I have a layout problem that I would think auto layout was designed to solve but I can't seem to get it to work. In short, I have three NSTextViews aligned vertically (with NSTextField labels between them) and I want them all to grow vertically but keep the space between them. The best I can get is to grow the bottom one, but the two above don't want to budge. Is there a trick to getting this to work, or is auto layout just not up to the task?
    >
    > My quick experiment says:
    >
    > A    top fixed to top of container
    > B    top fixed to bottom of A; height == height of A
    > C    top fixed to the bottom of B; height == height of B; bottom fixed to bottom of container.
    >
    > Delete all other vertical constraints; the above appears to be sufficient and consistent, so IB won't fight you. The Cocoa layout instrument doesn't see anything wrong.
    >
    > That's what I found in about three minutes. It worked for me.

    Thanks for that--it was because one of my views was taller than the other two (by design). Making them all the same height, then pinning height equal, is what did the trick.

    Is there comprehensive documentation somewhere? My search only brought up only rudimentary or code-only information.

    Keary Suska
    Esoteritech, Inc.
    "Demystifying technology for your home or business"
previous month may 2013 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Go to today