NSSplitter 如何防止调整大小时成比例的空间分布
我有一个窗口,右侧有一个源列表侧边栏,左侧有一个内容视图,两者都位于 NSSplitView 内。
当我调整窗口大小时,额外的空间将分配给源列表和内容视图。我怎样才能使源列表保持其固定宽度。所有苹果应用程序都这样做,所以我希望我只是错过了一个方法。
I have a window with a source list sidebar at the right side and a content view on the left both inside an NSSplitView.
When i resize the window, the additional space is distributed to the source list and the content view. How can i make the source list to maintain its fixed width. All Apple applications are doing this so i hope i just missed a method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 SnowLeopard 上,有一个名为
splitView:shouldAdjustSizeOfSubview:
的委托方法。您所要做的就是为您的源列表视图返回“NO”,您应该就可以了。如果您需要支持 Leopard 或更早版本,则必须实现 splitView:resizeSubviewsWithOldSize: 并手动调整子视图的大小,保持源列表视图的固定宽度,并调整其他视图的大小以填充拆分视图的边界(考虑到分隔线的宽度)。这两种方法都记录在此处
On SnowLeopard, there is a delegate method called
splitView:shouldAdjustSizeOfSubview:
. All you have to do is return NO for your source list view, and you should be good. If you need to support Leopard or earlier, you have to implementsplitView:resizeSubviewsWithOldSize:
and manually resize the subviews, keeping your source list view a fixed width, and resizing your other view to fill the split view's bounds (taking into account the divider's width).Both methods are documented here