Setting one side of an NSSplitView programmaticall

2019-03-27 07:26发布

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?

2条回答
\"骚年 ilove
2楼-- · 2019-03-27 07:59

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.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-03-27 08:07

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

查看更多
登录 后发表回答