以编程方式设置 NSSplitView 的一侧
我有一个 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在执行交换之前,尝试将新视图的框架设置为旧视图的框架。
Try setting the frame of your new view to that of the old view before performing the swap.
另外,您可以看看BWToolkit,它提供了一种更好的方法来设置尺寸分割窗格的两侧。
Also, you might take a look at BWToolkit which provides a much nicer way to set the sizes for the sides of a split pane.