user3068815
user3068815

Reputation: 27

How to place objects in tab view in a Xcode mac app?

How do I place objects (i.e. labels or buttons) in a tab view in an Xcode mac app, so that when I click on a different tab the associated objects appear. For example, I want to be able to put some labels in a tab called "Data" and some buttons in a tab called "Choice". When I press "Data" I want the labels to appear, but the buttons to not, and the other way around as well. Is there an easy way to do this? Do I need to make a different class for each tab?

Upvotes: 2

Views: 1754

Answers (2)

stevel
stevel

Reputation: 1622

Use the built in cocoa view NSTabView which you can find in interface builder:

NSTabView in interface builder

Each tab has its own view where you can place your objects.

Upvotes: 1

Anoop Vaidya
Anoop Vaidya

Reputation: 46563

Each of the NSTabView's tab consists of as NSView. Here either you can draw all the buttons, labels or any other controls. Even you can add your new view from same xib or load it from other xib.

In the following image you can see, I have used a tabview with two tabs and in the object view you can see two views having two different static text.

enter image description here

And the tab change/click event is fired automatically you dont need to worry about it, the view will be loaded on tab click/change.

Upvotes: 3

Related Questions