我需要使用自定义视图(NSView *mainContent),并根据用户从 NSPopUpButton 中的选择将视图换成不同的 nib。弹出按钮的 IBAction 方法如下所示:
- (IBAction)menuSelected:(NSPopUpButton *)sender {
NSInteger index = [sender indexOfSelectedItem];
NSLog(@"Selected button index is %ld", index);
[dynamicTitle.cell setTitle:[self returnSectionTitle:index]];
NSLog(@"%@", dynamicTitle.stringValue);
switch (index) {
case 0:
Sect1 = [[Sect1_View alloc] initWithNibName:@"Sect1_View" bundle:nil];
maincontent = Sect1.view;
[maincontent release];
break;
case 1:
Sect2 = [[Sect2_View alloc] initWithNibName:@"Sect2_View" bundle:nil];
break;
case 2:
Sect3a = [[Sect3a_View alloc] initWithNibName:@"Sect3a_View" bundle:nil];
break;
case 3:
Sect3b = [[Sect3b_View alloc] initWithNibName:@"Sect3b_View" bundle:nil];
break;
case 4:
Sect3c = [[Sect3c_View alloc] initWithNibName:@"Sect3c_View" bundle:nil];
break;
case 5:
Sect4 = [[Sect4_View alloc] initWithNibName:@"Sect4_View" bundle:nil];
break;
default:
break;
}
}
这似乎没有检索到新的笔尖,关于如何实现这一点的任何建议?
谢谢。