2

在此处输入图像描述

如何隐藏显示/隐藏按钮(在此处编辑为展开)。即使我将其设置为空字符串,数据单元格的边框也会缩小,如图所示。以前我使用过该方法- (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item,它隐藏了显示/隐藏字符串并且工作正常。但问题是大纲视图只允许展开而不是折叠。我想通过单击相应的父节点一次只展开一个父节点。

4

2 回答 2

10

从 NSOutlineViewDelegate 方法中使用此方法:

- (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item;
于 2014-09-12T15:34:39.440 回答
1

Finally solved it, this code helped me.

- (NSRect)frameOfOutlineCellAtRow:(NSInteger)rowIndex
{
    NSRect superFrame = [super frameOfOutlineCellAtRow:rowIndex];

    // Return NSZeroRect if the row is a group row
    if ([[self delegate] respondsToSelector:@selector(outlineView:isGroupItem:)]) {
        if ([[self delegate] outlineView:self isGroupItem:[self itemAtRow:rowIndex]]) {
            return NSZeroRect;
        }
    }


    return superFrame;
}
于 2013-05-16T05:21:48.540 回答