我正在使用此 IBActions 加载两个不同的视图
- (IBAction)showFirstView:(id)sender{
theDetailViewController = [DetailViewController new];
[theDetailViewController initWithNibName:@"DetailView" bundle:nil];
NSView *splitRightView = [[theSplitView subviews] objectAtIndex:1];
NSView *aDetailView = [theDetailViewController view];
[aDetailView setFrame:[splitRightView bounds]];
[aDetailView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
[splitRightView addSubview:aDetailView];
NSLog(@"%@",(NSString *)splitRightView);
}
- (IBAction)showSecondView:(id)sender{
theNewViewController = [NewViewController new];
[theNewViewController initWithNibName:@"NewView" bundle:nil];
NSView *splitRightView = [[theSplitView subviews] objectAtIndex:1];
NSView *aDetailView = [theNewViewController view];
[aDetailView setFrame:[splitRightView bounds]];
[aDetailView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
[splitRightView addSubview:aDetailView];
NSLog(@"%@",(NSString *)splitRightView);
}
但是使用此代码,我只是将堆栈一中的子视图放在彼此前面,如何在添加新子视图之前从splitRightView中删除子视图?
谢谢。