以编程方式设置NSSplitView的一侧 [英] Setting one side of an NSSplitView programmatically

查看:410
本文介绍了以编程方式设置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?

解决方案

Try setting the frame of your new view to that of the old view before performing the swap.

这篇关于以编程方式设置NSSplitView的一侧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆