如何隐藏显示/隐藏按钮(编辑为此处展开)。即使我将其设置为空字符串,数据单元格的边框也会缩小,如图所示。以前我使用方法- (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item
,它隐藏显示/隐藏字符串并完美地工作。但问题是outlineview只允许展开而不是折叠。我想通过单击相应的父节点一次只展开一个父节点。
答案 0 :(得分:10)
使用NSOutlineViewDelegate方法中的此方法:
答案 1 :(得分:1)
终于解决了它,this code帮助了我。
- (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;
}