Setting one side of an NSSplitView programmatically

≡放荡痞女 提交于 2019-12-04 22:13:12

问题


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?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/1419038/setting-one-side-of-an-nssplitview-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!