Saqib Omer
Saqib Omer

Reputation: 5477

Cocoa disable tabItem at index

I have a NSTabViewController which has two NSTabViewItem. I want to disable second tab.

class MainTabViewController: NSTabViewController {

// Properties
var data : [String: AnyObject]?


override func viewDidLoad() {
    super.viewDidLoad()
    let tabItem = self.tabView.tabViewItem(at: 1)
    tabItem.isSelectable = true


   }

}

as tabItem.isSelectable is a get only property, how can I disable and enableNSTabViewItem item.

Upvotes: 0

Views: 896

Answers (1)

Mr. Hedgehog
Mr. Hedgehog

Reputation: 986

You need to set the delegate for your tab view and implement func tabView(NSTabView, shouldSelect: NSTabViewItem?) method to return false if you need to disable a specific NSTabViewItem.

Upvotes: 4

Related Questions