6

In 10.10 Apple introduced some updates on AppKit with Storyboards and a few classes. One of those is NSTabViewController.

In the WWDC Session 212 the presenter showed some properties of the class. wwdc

Supposedly, the default NSSegmentedControl could be modified, or, setting tabStyle to NSTabViewControllerTabStyleUnspecified could enable us to modify the tabs style. The problem is that segmentedControl doesn't appear to be an available property on the SDK. Maybe it didn't made it to release? How can we change the style without it? My goal was to implement something like the Xcode 6 left tab.

enter image description here

1 Answers1

1

The way to do this is to create a tabless tab view and a custom segmented control whose action changes tabs inyour tab view.

You can fill a duplicate bug report at bugreport.apple.com:

  • rdar://34206798 NSTabViewController.h documentation is outdated
  • rdar://34206839 NSTabViewController should provide a way to customise its NSSegmentedControl
catlan
  • 25,100
  • 8
  • 67
  • 78
uchuugaka
  • 12,679
  • 6
  • 37
  • 55
  • 2
    I though about that and found this on the headers. /// Read and write the current selected TabViewItem that is being shown. This value is KVC compliant and can be the target of a binding. For instance, a NSSegmentedControl's selection can be bound to this value with: \code [segmentedControl bind:NSSelectedIndexBinding toObject:tabViewController withKeyPath:@“selectedTabViewItemIndex" options:nil]; But the WWDC presentation didn't make it clear. –  Nov 07 '14 at 00:30
  • That's pretty clear. It's just saying you can bind a segmented control to it to do what I described. Bindings will work fine for the simple case. – uchuugaka Nov 07 '14 at 00:36
  • 1
    Maybe I am missing something here, but how do you get a segmented control and a tabless tab view in the same view controller in interface builder? A standard NSTabViewController doesn't accept any other views. – user965972 Jan 31 '15 at 14:41
  • ah, well, you don't necessarily get them in the same one. You need to subclass or compose. Subclass NSTabViewController, (or just NSViewController) or probably better, you create your own NSViewController subclass that contains a segmented control and observes a tabview or tabviewcontroller. – uchuugaka Jan 31 '15 at 15:01
  • Subclassing lets you add anything you want to. On OS X for sure, almost never expect to use vanilla view controller classes. They're more like abstract base classes to provide common plumbing. – uchuugaka Jan 31 '15 at 15:04