How would one implement a sidebar similar to Mail/iTunes/Finder/etc in Cocoa/IB?

后端 未结 2 1199
南笙
南笙 2020-12-12 14:30

I think the title pretty much says it all... I\'m looking to implement an interface similar to the standard OS X sidebar used in all the above mentioned programs, and I\'m w

相关标签:
2条回答
  • 2020-12-12 14:34

    I've done a few applications that use a similar setup.

    I generally use an NSSplitView, with a single column NSTableView in the left pane. Don't forget to disable the headers, and make it display as a "Source View" style.

    If you want the disclosure triangles, then you'll want to use NSOutlineView instead of NSTableView, but at least for the first go, I'd stick to a simple NSTableView.

    A pattern I also use is to make the NSTableView slightly shorter than the NSSplitView, and have buttons at the bottom (add, delete, etc). I've usually built the program around Core Data, so it's easy to hook up these to methods to create/delete objects, and then bind the NSTableView to the array of objects.

    0 讨论(0)
  • 2020-12-12 14:50

    Direct support for this sort of thing was added in Leopard. It's called a 'source list'.

    Please see the AppKit release notes. Search for NSTableViewSelectionHighlightStyleSourceList in the document.

    Or, drag out a table view and select Highlight: Source List in Interface Builder.

    0 讨论(0)
提交回复
热议问题