NSOutlineView不折叠项目

NSOutlineView不折叠项目

本文介绍了NSOutlineView不折叠项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个NSOutlineView,点击一行将展开/折叠该项目,如果它是可扩展的。

I have a NSOutlineView, and clicking on a row will expand/collapse the item if it's expandable.

    if ([self.outlineView isItemExpanded:item]) {
        NSLog("Will collapse item : %@", item);
        [[self.outlineView animator] collapseItem:item];
    }
    else {
        [[self.outlineView animator] expandItem:item];
    }

展开项目按预期工作,但折叠项目无效。我在执行collapseItem:之前得到了日志,项目是正确的。委托方法 - (BOOL)outlineView:(NSOutlineView *)outlineView shouldCollapseItem:(id)item 也没有调用。

Expanding the item works as expected, however collapsing the item is not working. I did get the log before executing collapseItem:, and the item is correct. The delegate method - (BOOL)outlineView:(NSOutlineView *)outlineView shouldCollapseItem:(id)item was not called too.

已经有几个小时了。任何想法是什么原因导致的?

Have been on this problem for hours. Any ideas what causes this?

推荐答案

我想出来了。似乎项目是可折叠的只有当 - (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item 返回YES的项目。否则,您只能展开该项目。

I figured it out. Seems the item is collapsable only when - (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item returns YES for that item. Otherwise, you can only expand the item.

这篇关于NSOutlineView不折叠项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 21:02