我試圖修改在行展開/摺疊時我的NSOutlineView中使用的自定義NSTableRowView的外觀。我的NSOutlineViewDelegate包括:如何在NSOutlineView中重新加載自定義的NSTableRowView?
- (NSTableRowView *)outlineView:(NSOutlineView *)outlineView rowViewForItem:(id)item
{
...
return rowView;
}
- (void)itemDidExpand:(NSNotification *)notification
{
NSDictionary *userInfo = [notification userInfo];
id item = [userInfo objectForKey:@"NSObject"];
NSOutlineView *outlineView = [notification object];
[outlineView reloadItem:item];
}
這不幸的是不會重新加載自定義行視圖。整個NSOutlineView
重新加載數據的工作原理:
- (void)itemDidExpand:(NSNotification *)notification
{
[outlineView reloadData];
}
但隨着大量的數據這可能是耗時的,並且經常導致紡紗沙灘球。
是否有可能只爲單個頂級項目重新加載自定義行視圖?
您是否在嘗試修改顏色或其他? –
是的,自定義表格行視圖會覆蓋drawSeparatorInRect:和drawBackgroundInRect:根據項目是展開還是摺疊來更改顏色。 –
我在下面提供了一個解決方案。讓我知道它是否工作 –