Question

I am doing some king of Property Inspector View. I Am using Auto Layout with Custom Layout (setting the frame property explicitly) only on the outer panel. Let me explain:

  • Each line of the inspector property view is implemented by a InspectorPropertyCell which uses only Autolayout.
  • There is a StackPanel custom control which stacks the cells and uses autolayout too. For each group there is a stack panel associated. The Group 04 is inside Group 03. Both are collapsible.
  • There is an outer stack panel that stacks all the groups. This outer stack panel sets the height explicitly by using the frame property.
  • This is all contained inside a NSScrollView.

See an image:

enter image description here

Everything works fine but if I resize the window to have its content area smaller that the whole property inspector view (so I can scroll the property inspector view), then scroll to the bottom and then collapse the last group (Group 04), the property inspector view shrinks and acts correctly. Also, the scroll viewable regions is adjusted accordingly. The problem is that I can't undo the collapsing of group 04.

By setting a few breakpoints in the code, I discovered what the problem is. I just don't know how to solve it. The problem is that while the updateConstraints pass is called (because I call -setNeedsUpdateConstraints), the -layout pass is not called. Even if i force a layout pass by calling -layoutSubtreeIfNeeded, the auto layout doesn't seem to be having a effect because the height of some cells that I set to 0 (using a constraint), when I do the collapsing, is still 0 when I uncollapse.

The layout pass gets called again If I resize the window. Of course, this is unacceptable.

Please, Help!!! I am about to drop Auto Layout entirely and do custom layout using only Layout...

Was it helpful?

Solution

I solved by calling layout on the subviews explicitly... That's a little weird... But I need my children layouted before I layout myself (the StackPanel).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top