2

I made a very simple dummy project to illustrate my problem (using Xcode 8.1 on 10.12.1). I have a storyboard with an NSTabViewController with 2 tabs, one of which is an NSSplitViewController. Although everything seems to work perfectly, I see the following warning at runtime:

"TabSplitViewDummy[3615:89221] [Layout] Detected missing constraints for <_NSSplitViewItemViewWrapper: 0x6000001a0d20>. It cannot be placed because there are not enough constraints to fully define the size and origin. Add the missing constraints, or set translatesAutoresizingMaskIntoConstraints=YES and constraints will be generated for you. If this view is laid out manually on macOS 10.12 and later, you may choose to not call [super layout] from your override. Set a breakpoint on DETECTED_MISSING_CONSTRAINTS to debug. This error will only be logged once."

I've tried to set translatesAutoresizingMaskIntoConstraints=YES for all views as well as setting constraints - nothing worked. So far I only found out 3 things:

  1. when I change the order of the tabs so that the split view is invisible at launch, there is no warning message
  2. when I remove the tab view and make the split view content of the window, there is no warning message
  3. when I set a symbolic break point on DETECTED_MISSING_CONSTRAINTS, it gets hit 6 times, so I guess there are 6 missing constraints

I've already lost days with this, what am I missing here?

Thanks a lot for your help!!!

GitHub dummy project

MikeElmwood
  • 270
  • 2
  • 11

1 Answers1

1

After almost loosing it, I finally found the solution. Just in case someone else is going through the same trouble, here is what worked for me: go to the storyboard and connect the "view" outlet of the NSTabViewController to the "No Shadow Tab View". That's it. You d'expect Xcode to do that when you set up a new NSTabViewController but it doesn't. I'don't fully understand why, but somehow this messes with the Autolayout of the NSSplitView. If you can explain this in detail, please do so in the comments.

MikeElmwood
  • 270
  • 2
  • 11
  • I'm getting the same issue after connecting the view of the tab vc. – Jimmy Hough Jr Nov 01 '16 at 18:00
  • That's weird. I just rechecked the dummy project and it still worked for me. Did you try it in your own project or did you download my dummy project? Maybe there there are some other things that have to be set in the right way too, like autoresizing or constraints or something...? – MikeElmwood Nov 01 '16 at 19:45
  • I have the same problem with a tab view using the toolbar display. I tried your solution, but then the toolbar is not visible anymore. – Frédéric T. Nov 03 '16 at 20:11
  • I'm not sure I understand exactly what your set-up is and I guess the details are crucial to reproduce these errors. Out of curiosity, I tried to set the style of the TabViewController in the dummy project from "Tabs on Top" to "Toolbar" (is this, what you have?). This did not generate the layout error and seemed to work fine at first. However, it generated 3 runtime errors concerning a "NSTabViewControllerToolbarUIProvider" (never heard of it before). Details: [link](https://forums.developer.apple.com/thread/14237) But then again, I've never tried this before, so this may be simply my fault. – MikeElmwood Nov 04 '16 at 08:49
  • By the way, in the project I'm currently working on I have a TabViewController with the style "Unspecified" and a NSSegmentedControl in the toolbar. This button calls '@IBAction func selectTab(_ segmentedControl: NSSegmentedControl)' in my window controller, which then selects the right tab by calling 'func selectTabViewItem(withIdentifier identifier: Any)' on the tab view. This works fine since I set the No Shadow Tab View as view of the tab view controller. – MikeElmwood Nov 04 '16 at 09:01
  • I used to have my split view as the initial view controller in the storyboard. For an unrelated reason, I added an NSWindowController from the library, set the split view as its content view and set the window controller as the initial view controller. The error disappeared. May be a coincidence though. – hashemi Jul 02 '17 at 22:18