0

Im developing an osx application in Swift 4 to be displayed in the menu bar and call a popover when clicked to display a number of different views.

My structure in Storyboard is: NSView > Container View > Tab View

This lets me maintain a top menu bar while being able to change between tabs.

I have hidden the buttons in the NSTabView and have managed to change between views on load using the following code:

import Cocoa

class TabViewController: NSTabViewController {

@IBOutlet weak var theFirstTab: NSTabViewItem!

override func viewDidLoad() {
    super.viewDidLoad()
    changeTab()
}

func changeTab() {
    let theTabView = theFirstTab.tabView
    theTabView?.selectTabViewItem(at: 3)
}

}

When I start my application this loads the 3rd tab programatically which is great!

What I want to do however is create my own menu in the parent ViewController to call this function so that the tabs change within the container.

Is it possible to call this function from the parent somehow?

Ive searched all over for a solution to this problem and am so close but hopefully someone here can help me. I can add pictures of my storyboard if this is not clear enough?

Thanks in advance.

EHarpham
  • 602
  • 1
  • 17
  • 34
  • You can even make the settings in Interface Builder that the 3rd tab is the default tab. By the way: `selectTabViewItem(at: 3)` selects the **4th** tab – vadian Jun 29 '18 at 09:03
  • Thanks for the comment I will adjust my question. Yes im aware you can set in interface builder but that is not what im trying to achieve ;) – EHarpham Jun 29 '18 at 09:09

0 Answers0