如何在Cocoa / IB中实现类似于Mail / iTunes / Finder / etc的边栏? [英] How would one implement a sidebar similar to Mail/iTunes/Finder/etc in Cocoa/IB?

查看:151
本文介绍了如何在Cocoa / IB中实现类似于Mail / iTunes / Finder / etc的边栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为标题相当多地说这一切...我正在寻找实现类似于所有上述程序中使用的标准OS X边栏的界面,我想知道是否有任何人有任何想法最简单的方法,即关于用于左手选择窗格的视图。真的,我不认为我甚至需要等级组件,如苹果应用程序中所见,我只需要一个好看的平滑的选择列表,确定右侧窗格中显示的内容。

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 wondering if anybody has any thoughts as to the easiest way to do it, namely about what view to use for the left hand selection pane. Really I don't think I even need the hierarchical component as seen in the apple apps, I just need a good looking flat list of choices which determine what's shown in the right hand pane.

明显的开始是垂直拆分布局视图,但除此之外,我不完全确定去哪里。

The obvious start is a vertical split layout view, but beyond that I'm not entirely sure where to go. A collection view with only one column or something like that?

推荐答案

我做了一些使用类似设置的应用程序。

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

我通常使用NSSplitView,在左窗格中有一列NSTableView。不要忘记停用标题,并将其显示为源代码视图样式。

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.

如果你想要公开的三角形,那么你会想使用NSOutlineView而不是NSTableView,但至少第一次去,我会坚持一个简单的NSTableView。

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.

我还使用的模式是使NSTableView稍短于NSSplitView,底部有按钮(添加,删除等)。我通常围绕Core Data构建程序,所以很容易将这些链接到创建/删除对象的方法,然后将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.

这篇关于如何在Cocoa / IB中实现类似于Mail / iTunes / Finder / etc的边栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆