Trombone0904
Trombone0904

Reputation: 4268

reload tab controller item

is it possible to reload a tab controller item every time i pressed a button?

for example:

class TabController: NSTabViewController {

    @IBAction func showFirstTab(_ sender: NSButton) {
        self.selectedTabViewItemIndex = 1
    }

}

i would like to reload the view of tab item 1 every time i pressed the tab. i work with swift 3 for osx.

Upvotes: 1

Views: 170

Answers (1)

Utkarsha
Utkarsha

Reputation: 250

You can use below UITabView delegate method and reload your view each time the tab is pressed. It informs the tab view controller that the specified tab is about to be selected.

To differentiate between the tab items you can set the NSTabViewItem identifier.

func tabView(_ tabView: NSTabView, willSelect tabViewItem: NSTabViewItem?)

Upvotes: 1

Related Questions