以编程方式设置NSSplitView的一侧 [英] Setting one side of an NSSplitView programmatically
问题描述
我有一个 NSSplitView
,在左侧我有一个tableView(像源列表),根据行选择,我想更改右侧分割视图。
当我添加我想要的子视图到splitview,它添加另一个拆分(所以现在总共有3个视图。不是我想要的)。
[mySplitView addSubview:myCustomView];
如何正确设置我的splitView的右侧?
更新
使用
[mySplitView replaceSubview:[[mySplitView subviews] objectAtIndex:1] withSubview:myCustomView]
似乎工作,但是它调整分裂视图的大小奇怪,我怎么可以停止这?在IB中,有一个选项可以关闭 autoResizesSubviews
,但我不能取消选中。任何想法?
尝试在执行交换之前将新视图的框架设置为旧视图的框架。 >
I've got an NSSplitView
and on the left side I've got a tableView (like a source list) and depending on row selection, I want to change the the right side of the split view. I can't quite figure out how to do this.
When I add my desired subview to the splitview, it adds another split (so now there's 3 views total... not what I wanted).
[mySplitView addSubview:myCustomView];
How do I properly set the right side of my splitView?
Update
Using
[mySplitView replaceSubview:[[mySplitView subviews] objectAtIndex:1] withSubview:myCustomView]
Seems to work, however it's resizing the split view rather oddly, how can I stop this? In IB there's an option to turn off autoResizesSubviews
but I can't uncheck this. Any ideas?
Try setting the frame of your new view to that of the old view before performing the swap.
这篇关于以编程方式设置NSSplitView的一侧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!