1

我有一个 NSTabView,我在其选项卡上分配和加载相同的 NSViewController:

IRCView *viewirc = [[IRCView alloc] initWithNibName:@"IRCView" bundle:nil];
for (id view in [tabsView tabViewItems]) {
     [view setView:[viewirc view]];
}

如何IRCView在每个选项卡上加载不同的视图控制器“实例” NSTabView?因此,每个选项卡都可以与 IRC 服务器有不同的连接(在本例中)

4

1 回答 1

1
for(NSTabViewItem * tabViewItem in [tabsView tabViewItems])
{
    // instantiate a brand new IRCView for each tab view item...
    IRCView *viewirc = [[IRCView alloc] initWithNibName:@"IRCView" bundle:nil];

    // ... and do whatever customization you want to do for each IRCView here

    [tabViewItem setView: viewirc];
    [viewirc release]; // tabViewItem already retains
}
于 2011-11-12T15:04:11.760 回答