NSOutlineView Changing disclosure Image

前端 未结 5 2157
青春惊慌失措
青春惊慌失措 2020-12-30 16:56

I my outline view, i am adding Custom cell, To drawing custom cell, i am referring example code , present in the Cocoa documentation

http://www.martinkahr.com/2007/0

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-30 17:28

    After researching this issue myself, and trying some of the answers here, I have found that the other approaches mentioned will work, but will require that you perform a lot more manual intervention in order to avoid screen artifacts and other strange behavior.

    The simplest solution I found is the following, which should work in most cases.

    This solution has the added benefit of the system automatically handling a great many other cases, such as column movement, etc, without your involvement.

    - (void)outlineView:(NSOutlineView *)outlineView willDisplayOutlineCell:(id)cell
         forTableColumn:(NSTableColumn *)tableColumn
                   item:(id)item
    {
        [cell setImage:[NSImage imageNamed: @"Navigation right 16x16 vWhite_tx"]];
        [cell setAlternateImage:[NSImage imageNamed: @"Navigation down 16x16 vWhite_tx"]];
    }
    

    In your case, you would wrap this up with your class detection logic, and set the cell images appropriately for your cases.

提交回复
热议问题