NSTableView,多个单元格和绑定

发布于 2024-08-05 04:26:03 字数 439 浏览 6 评论 0原文

我正在尝试创建一个类似于 Motion 属性视图的视图。

ScreenShot

我的每个属性对象都包含它想要显示的单元格类型的定义。但同时,我想使用绑定,以便值可以在其他地方更改时自动更新。

我尝试了几种不同的方法来解决这个问题。

  • 多个单元格和dataCellForTableColumn:虽然这允许所有单元格类型正确渲染,但我会丢失绑定。

  • NSProxy:我也尝试过使用代理对象,我认为该对象会将所有方法转发到其后面选定的单元格类型,但同样,绑定似乎在这里不起作用。

以前有人遇到过此类问题吗?或者这是绑定无法解决问题的情况之一,我需要自己做繁重的工作?

干杯!

I'm trying to create a view that's similar to Motion's properties views.

ScreenShot

Each of my property objects contains a definition of the kind of cell it wants to display as. But at the same time, I'd like to use bindings so that values are automatically updated as they can be changed elsewhere.

I've tried a few different approaches to the problem.

  • Multiple cells and dataCellForTableColumn: while this allows rendering to happen properly for all cell types, I lose bindings.

  • NSProxy: I've also tried using a proxy object that I thought would forward all methods to the selected cell type behind it, but again, bindings don't seem to work here.

Has anybody had any experience with this kind of problem before? Or is this one of the cases where bindings isn't going to cut it, and I'll need to do the heavy lifting myself?

Cheers!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拔了角的鹿 2024-08-12 04:26:03

我还没有实际测试过它,但是当您使用 dataCellForTableColumn:row: 时,您不应该丢失绑定?您能否更详细地描述一下您在绑定方面所做的尝试?

您应该能够将列的值绑定设置为对象的“value”属性。然后,如果您在 dataCellForTableColumn:row: 中返回正确的单元格类型,它应该正确显示。

编辑:---删除了关于单元格与视图的无端错误建议:)

I haven't actually tested it, but you shouldn't be losing bindings when you use dataCellForTableColumn:row: ? Can you describe in a bit more detail what you've tried with respect to bindings?

You should be able to set the column's value binding to the "value" property of your object. Then if you return the correct type of cell in dataCellForTableColumn:row: it should display correctly.

Edit: --- deleted gratuitous incorrect advice about cells vs views :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文