NSSplitViewController almost never starts with the correct size

I have this application that uses NSSplitViewController as root and has NSTabViewController connected as its detailViewController.

This application runs with a resolution of 1024x768. The left panel should start at 320x768, and the right panel (where the tabViewController) should start at 704x768.

From 10 times I run this application, 9 times it starts with the wrong size (about 500x500). Another strange thing is that this application should not be scalable, but if you hover over the border of the window, you will see a cursor indication for scaling.

I want this to start at the right size and not have a scalable option.

Both of these parameters are on the interface constructor, but are ignored.

You can download an example project that demonstrates the problem here . Stop and run the project several times to see the problem.

How to solve this?

+7
cocoa macos nstabviewcontroller nssplitviewcontroller
source share
1 answer

I could not say exactly what caused the problem, but one way to solve this problem is to add some limitations. The Builder interface does not allow you to restrict the default instances of NSView that it inserts into the left and right panels of the split view, so you need to add your own. The screenshot below is taken from your demo, but after I did the following:

  • A subview has been added to the left section (My Content View) and attached to the edges of its supervisor (Xcode viewing automatically adds to splitview).
  • Added a cell width limit of 320 pixels to My Content

enter image description here

When I download the application, both delimiters are visible, the divider does not move, and the window cannot be resized.

Update is the best solution.

Although limitations are one way to solve this problem, I think the root of the problem lies in the unexpected behavior in Interface Builder. When you drag an NSSplitViewController object NSSplitViewController the canvas and make it an object of communication with the content window manager, the output board of the split view manager is not installed. One of the consequences of this, apparently, is that when loading the application, the separator will be on the right side. To solve this problem, install the aforementioned outlet to display as a split:

enter image description here

I created a demo project with a setting similar to that in the polling demo application.

+19
source share

All Articles