I am coding an MacOS app with swift. The main layout in the window is like follows:
The NSStackView has a sideBar (NSTableView) and a NSView. What I want to achieve is listed here:
- The width of the sideBar is fixed when changing the window size.
- When the width of the window is smaller than
WIDTH_THRESHOLD
, the sideBar is hidden.
The problems are
- For Target 1, the constraints of the sideBar and the NSView is like follows, but it doesn't work and the width of the sideBar still changes.
- For Target 2, the project has a
NSWindowController
and aNSViewController
. I can listen the window size inNSWindowController
, but I don't know how to transport this msg to theNSViewController
to hidden the sideBar.
Notice that NSStackView has the properties like Hugging Priority
, Clipping Resistance Priority
and Visibility Priorities
in size inspector, can I achieve the targets through setting these properties (in the following figure)?