0

I would like to make an "inspector sidebar" in a macOS window. You know the inspector in Xcode:

Xcode inspector

The sidebar's content should be context sensitive. Depending on the user's selection in the main window there should be different dialogs.

Which technologies do I have to use to get this behavior?

My attempts were (in Storyboard):

  1. Insert a Split View into the window.
  2. Insert a Tab View Controller into the right Custom View of the Split View

But this didn't worked: I could easily insert the Split View into the window. And I could easily insert a Tab View Controller to the Storyboard. But I was not able to insert the Tab View Controller into the right view of the Split View.

So how do I achieve the desired behavior?

Michael
  • 51
  • 1
  • 8
  • Insert the TabView control, not a view controller into the Split guy. – El Tomato Nov 05 '20 at 22:58
  • @ElTomato, when I use a TabView control, how can I setup ViewControllers for the different dialogs? – Michael Nov 06 '20 at 09:33
  • What are the things that you call 'different dialogs'? – El Tomato Nov 06 '20 at 23:32
  • @ElTomato, I don't know the exactly term. For example, in a Xcode storyboard: When I select a SplitView, I get a special "dialog" in the inspector where I can customise the SplitView (see the picture above). When I select another object, I get a different "dialog". The same way I would like to have different "dialogs" in the sidebar, each with different controls. – Michael Nov 10 '20 at 21:25
  • How did you insert the Split View Controller into the window? – Willeke Nov 11 '20 at 23:07
  • @Willeke, in Storyboard: First I have a ViewController Scene with a ViewController. The ViewController has a View which has a SplitView. The SplitView has two CustomViews. Now I could insert a TabView into the second CustomView (but how do I get controllers for the different tabs?). Or I could insert a TabViewController into the storyboard. But how do I insert the tabs into the CustomView of the SplitView? – Michael Nov 12 '20 at 13:10
  • Use a Split View Controller? – Willeke Nov 12 '20 at 13:52

1 Answers1

0

Finally I solved the issue. I had to add a CustomView to each of the tab's CustomViews. This way, Xcode added ViewControllers automatically. Here are the individual steps:

First, I had to insert a SplitView into the storyboard. Nothing problematic here yet.

SplitView

Second, I've added a TabView (Style: tabless) into one of the CustomViews:

SplitView with TabView

And third, I needed to add ContainerViews to each of the tabs:

SplitView with TabViews with ContainerViews

This way Xcode added ViewControllers for each of the tab's ContainerViews:

enter image description here

No I can chose the different Tabs programmatically:

@IBAction func showInspector1(_ sender: NSButton) {
    self.tabView.selectTabViewItem(at: 0)
}
@IBAction func showInspector2(_ sender: NSButton) {
    self.tabView.selectTabViewItem(at: 1)
}

I would like to thank for the comments, that helped me making progress and solving this issue.

Michael
  • 51
  • 1
  • 8