如何从可可中的 NSSplitView 中删除子视图?
我正在使用此 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 中删除子视图?
谢谢。
I'm loading two different views with this 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);
}
but with this code I'm just getting the subviews in stack one in front of each other
how do i remove the subview from splitRightView before adding the new subview?
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个(假设你想删除第一个子视图):
Try this (assuming you want to remove the first subview):