Creating a tab view using Cocoa / Objective C

I need to create a tab view programmatically using object C and cocoa, but I cannot find any good resources showing how to do this. Can anyone suggest something?

+3
source share
1 answer

This adds a viewport to the window:

   NSTabView *tabView = [[[NSTabView alloc]
      initWithFrame:NSMakeRect(10,10,300,300)] autorelease];
   [[window contentView] addSubview:tabView];

This adds a tab to the tab view:

   NSTabViewItem *item = [[[NSTabViewItem alloc]
      initWithIdentifier:@"tab1"] autorelease];
   [item setLabel:@"Tab 1"];
   [tabView addTabViewItem:item];

At this point, you will want to add some controls to the tab. You must definitely do this using the interface. Create a tip with a view, make the owner of the NSViewController file. Then follow these steps:

   NSViewController *viewController = [[[NSViewController alloc]
      initWithNibName:@"myView" bundle:nil] autorelease];
   [item setView:[viewController view]];
+11
source

Source: https://habr.com/ru/post/1720007/


All Articles