在 NSTableView 中扩展行

Expanding Rows in NSTableView

是否可以像 NSOutlineView 一样在 NSTableView 中添加 collapse/expand 行?

我想在 NSTableView 中模仿 NSOutlineView 的行为。

您可以使用 NSTableView.hideRows(at indexes: IndexSet, withAnimation: NSTableView.AnimationOptions = []) 隐藏行。

您可以使用 NSTableView.unhideRows(at indexes: IndexSet, withAnimation rowAnimation: NSTableView.AnimationOptions = []) 显示行。

您可以通过NSTableView.hiddenRowIndexes获取隐藏行的索引。

请注意,隐藏和显示行会触发某些 NSTableViewDelegate 方法。有关详细信息,请参阅文档。