我尝试拨打setNeedsDysplay:
和setNeedsDisplayInRect:
,但{@ 1}}和drawBackgroundInRect:
没有为小组行调用,而是为其他所有内容调用
这是我的一段代码:
drawSeparatorInRect:
修改
这就是我提出的:
- (void)outlineView:(NSOutlineView *)outlineView didAddRowView:(NSTableRowView *)rowView forRow:(NSInteger)row {
id prevItem = [outlineView itemAtRow:row - 1];
if ([self outlineView:outlineView isGroupItem:prevItem]) {
id view = [self outlineView:outlineView rowViewForItem:prevItem];
if (view) {
[view setNeedsDisplay:YES];
}
}
}
......但在某些情况下它太慢了
答案 0 :(得分:0)
好的,这就是诀窍:
- (void)outlineViewItemDidCollapse:(NSNotification *)notification {
NSInteger row = [_outlineView rowForItem:notification.userInfo[@"NSObject"]];
NSView *rowView = [_outlineView rowViewAtRow:row makeIfNecessary:NO];
[rowView setNeedsDisplay:YES];
}
- (void)outlineViewItemDidExpand:(NSNotification *)notification {
NSInteger row = [_outlineView rowForItem:notification.userInfo[@"NSObject"]];
NSView *rowView = [_outlineView rowViewAtRow:row makeIfNecessary:NO];
[rowView setNeedsDisplay:YES];
}