【问题标题】:LOad different instances of the same NSViewController on NSTabView在 NSTabView 上加载相同 NSViewController 的不同实例
【发布时间】:2023-03-29 16:31:02
【问题描述】:

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

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

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

【问题讨论】:

    标签: macos cocoa nsview viewcontroller nstabview


    【解决方案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
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-21
      • 1970-01-01
      • 2012-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多