1

I have a class that inherits from NSSplitViewController and overrides the splitViewDidResizeSubviews function.

When I call collapse on a NSSplitViewItem inside the NSSplitViewController and I see the NSSplitViewItem visibly resize the splitViewDidResizeSubviews function isn't called.

If I resize the window the splitViewDidResizeSubviews function is called so I know it is implemented correctly.

Can I expect the splitViewDidResizeSubviews function to be called on a collapse and if so what might I be doing wrong?

4

1 回答 1

2

因为折叠 splitViewItem 不会调整其实际帧大小,而只是切换项目的可见性。isCollapsed如果您只是切换状态,则 splitViewItem 会保存帧大小。

(一个例外是当 item 向外扩展时。即splitViewItem.collapseBehavior = .preferResizingSplitViewWithFixedSiblings。正如我测试的那样,它调用splitViewDidResizeSubviews。)

因此,对于这种用法,我更喜欢覆盖 NSSplitViewController 的另一种方法,例如:

func splitView(_ splitView: NSSplitView, shouldCollapseSubview subview: NSView, forDoubleClickOnDividerAt dividerIndex: Int
于 2016-10-16T14:33:31.387 回答