I have an app that shows "chapters and pages" in an NSOutlineView
.
To make it clear to the user that "chapters" can contain "pages", I'd like the outline view to always show the disclosure triangle for chapters, even if they have no pages in them (i.e. are empty).
Here's an example:
Note how the first chapter is empty (no pages) and has no disclosure triangle.
I'd like the triangle to show up so that when users click on it, they realize that this is a "container" item that can contain other items.
I tried implementing various delegate methods, but could not get the disclosure triangle to show for empty entries.
Sample project: https://www.dropbox.com/s/fdggjod78t0isjr/OutlineViewTest.zip?dl=0
Ok, now I see. You're using Cocoa Bindings which assumes that some of the dataSource
methods shouldn't get called. As displayed at the NSOutlineViewDataSource reference page
'- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item'
IMPORTANT
While this method is marked as @optional in the protocol, you must implement this method if you are not providing the data for the outline view using Cocoa bindings.
Just try to implement it without Cocoa Bindings. Or you can find the way to break into the binding process and find out how to reject disclosure button deletion.
Yep, there's a third way. You can create MyTableCellView.xib and add your own disclosure button as well.
UPD
To determine, which item should have disclosure triangle, there's a Leaf
key path at the Tree Controller
attributes inspector tab.
Don't forget to add models' values to your data like that
@{@"title": @"Chapter 1 (empty)", @"isLeaf":@(NO)}