NSTableView,多个单元格和绑定
我正在尝试创建一个类似于 Motion 属性视图的视图。
我的每个属性对象都包含它想要显示的单元格类型的定义。但同时,我想使用绑定,以便值可以在其他地方更改时自动更新。
我尝试了几种不同的方法来解决这个问题。
多个单元格和
dataCellForTableColumn:
虽然这允许所有单元格类型正确渲染,但我会丢失绑定。NSProxy:我也尝试过使用代理对象,我认为该对象会将所有方法转发到其后面选定的单元格类型,但同样,绑定似乎在这里不起作用。
以前有人遇到过此类问题吗?或者这是绑定无法解决问题的情况之一,我需要自己做繁重的工作?
干杯!
I'm trying to create a view that's similar to Motion's properties views.
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我还没有实际测试过它,但是当您使用 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 :)