NSSplitView and autolayout

后端 未结 9 2000
暗喜
暗喜 2021-02-02 10:55

How should I use auto layout constrains inside NSSplitView subview?

My NSSplitView subview has 3 subview: topPane, tableCont

相关标签:
9条回答
  • 2021-02-02 11:46

    I found out that this error appears if I have toolbar in my window and control split view by any of this delegate methods:

    splitView:constrainMinCoordinate:ofSubviewAt:   
    splitView:constrainMaxCoordinate:ofSubviewAt:
    splitView:shouldAdjustSizeOfSubview:
    

    Solution was found in attaching toolbar to window in windowDidLoad.

    0 讨论(0)
  • 2021-02-02 11:47

    For anyone who stumbles onto this in the future and is looking for a jump-start into constraint-based NSSplitView replacements, I wrote a small project here that attempts to recreate a portion of NSSplitView's features using Auto Layout:

    https://github.com/jwilling/JWSplitView

    It's somewhat buggy, but it could be a useful reference to anyone wanting to go this route.

    0 讨论(0)
  • 2021-02-02 11:47

    As much as I hate to disagree, but Auco's answer should't be voted highest. It is not in any way helpful in solving the problem with an adequate amount of work. In my opinion the NSSplitView was only ever a problem to those who didn't read the documentation well enough.

    The actual solution to the problem mentioned here is fairly simple: Auto Layout introduced the new "Holding Priorities API" on NSSplitView. And as the documentation says: Setting lower values to the holding priority of a subview will make him more likely to take width earlier. All of this can be set in IB and programmatically without any despair. The amount of work needed: 20 seconds approx.

    0 讨论(0)
提交回复
热议问题