Search code examples
objective-cxcodecocoansoutlineview

Create Xcode-like Outline View header


OK, this what I'm trying to replicate :

enter image description here

I suppose that is an NSOutlineView - a "Source List"-type one actually. I'm used to be working with NSOutlineViews with ImageAndTextCell.

  • Is it a view-based NSOutlineView or should I still use ImageAndTextCell?
  • How am I to draw a different background for this specific "Header" element?
  • How would you go about it?

Solution

  • How about using a view-based NSTableView and returning different views for the header and item rows (let's call them..)?

    I suppose you could have a NSTableViewDelegate that would depending on what type is required return from its tableView:viewForTableColumn:row: method either a header-type or item-type view prototype depending on the row (index)?

    Not sure if views returned by that method are allowed to have different heights or if you've got to handle that separately. If view-based table views are not smart enough to do it on their own you might have to implement - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row as well to set row heights appropriately for headers/items.