Pregunta

enter image description here

how to hide show /hide button (edited as expand here). even i set it as empty string ,the border for the data cell shrinks as shown in image. previously i used the method - (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item , it hiding the show/hide string and working perfectly. but the problem is the outlineview allows only expanding not collapsing. i want to expand only one parent at a time by clicking the corresponding parent node.

¿Fue útil?

Solución 2

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;
}

Otros consejos

Use this method from NSOutlineViewDelegate method :

- (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item;
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top