objective-cmacoscocoanstabviewnstabviewcontroller

Cocoa - NSTabViewController, how to change tabview on button press?


I've spent the past few days trying to work this out. Basically, when a user presses a button in my first tab, I want the the tabview to change to the next tab.

Here's how my storyboard looks. More specifically, when a user presses Youtube in my Homepage tab, I want FirstWebController to open.

Every method Ive found online hasn't worked, so I was hoping someone could provide some insight into next step I should take.

Thanks in advance.


Solution

  • Set the NSTabViewController's selectedTabViewItemIndex to the index of the tab item you want to select and it will change. You do have to keep track of the positions of the tab view items so you know which index is which but that's really only something you have to worry about if your tab view items are dynamic.