NSSplitViewController gives child view different size each time the app starts

541 views Asked by At

I'm using Autolayout & NSSplitViewController to develop a OS X app with two split views. But every time I run the app, the split views have different size. Sometimes it shows:

enter image description here

But sometimes:

enter image description here

What I want is the left panel have a min width of 150 and an initial width of 200. The right panel have a min width of 200 and take the rest space at the initial time.

What I do are followings:

  1. Add a NSSplitViewController and set it as the window content of the NSWindowController.
  2. Resize the left panel to the width of 200(which I want to be the initial width, but it seems not working), and add a Table View to it. Then give the table view a min width constrain of 150.
  3. Add a Custom View to the right panel and give it a min width constrain of 200.
  4. Set the holding priority of the right splitViewItem to 249.
  5. Set the view outlet of the SplitViewController to the split view.

Here's my Xcode screenshot: enter image description here The code are here: https://github.com/luin/sample-NSSplitViewControlller

0

There are 0 answers