在 Cocoa/Objective-C 中实现项目可视化列表(例如事物)的最佳方法是什么
我想用 Objective-C 创建一个项目列表,就像 Things 中的任务列表一样...如下所示:
https://skitch.com/mattfordham/r4t5a/things
每个项目都可以有与之关联的按钮、文本等。 NSTableView 是我的第一个想法,但似乎我可以根据需要自定义它。也许每一行都是一个自定义 NSView,我手动管理列表中每个项目的位置?感谢您的任何帮助。
I am wanting to create a list of items in with Objective-C like the list of tasks in Things... like this:
https://skitch.com/mattfordham/r4t5a/things
Each item could have buttons associated with it, text, whatever. NSTableView was my first thought, but seems I can customize it as much as I am needing. Perhaps each row would be a custom NSView and I manage the positioning of each item in the list manually? Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
NSTableView
和NSCollectionView
都允许自定义单元格/视图 - 事实上,它们是后者所必需的。我个人会使用NSTableView
来实现类似于您所描述的内容。您还可以使用第三方类,例如 PXListView,其源代码是开放的,并根据新的 BSD 许可证获得许可。或者,正如 David Barry 提到的,Chameleon 项目。
Both
NSTableView
andNSCollectionView
allow custom cells/views — in fact, they’re required for the latter. I’d personally useNSTableView
for something similar to what you’ve depicted.You could also use third party classes like PXListView, whose source code is open and licenced under the new BSD licence. Or, as mentioned by David Barry, the Chameleon Project.
也许不是最好的方法,但一种可能是使用基本上是 UIKit 的 Chameleon 项目对于 OS X。这将允许您使用 UITableview,它使用 UIView 来显示每一行。这应该使您可以更轻松地根据自己的喜好自定义行。
如果您将其用于一个界面元素(并且没有计划在 OS X 和 iOS 之间共享代码),并且如果您还没有任何 UIKit 经验,那么添加完整的 Chameleon 框架可能有点过分了将增加学习曲线。
Maybe not the best way, but one possibility may be using the Chameleon Project which is basically UIKit for OS X. This would allow you to use a UITableview, which uses a UIView to display each row. This should make it much easier for you to customize your rows to your hearts content.
It may be overkill adding the full Chameleon Framework if you'll one be using it for the one interface element(and have no plans of sharing code between OS X and iOS), and if you don't have any experience with UIKit already that will add to the learning curve.