1

I have an NSOutlineView, with its content bound to an appropriate NSTreeController. It works perfectly well, except when my app loads, only about half of the content of the NSOutlineView displays.

If I cmd+tab away and back, all the content displays. If I click the blank rows where I know there should be content, the text in the row I clicked suddenly appears. So the content's there, it's just not refreshing properly. I guess I need to send the NSOutlineView a needsDisplay message or something similar, but I'm not quite sure where.

This seems pretty illogical to me - the NSOutlineView should surely be able to display its content properly when bound. Is there something obvious that I'm missing?

4

3 回答 3

0

根据苹果文档,您应该始终-reloadData在创建大纲视图后发送到大纲视图。在您的情况下,这将是您的 NIB 完成加载的任何地方(-awakeFromNib? -applicationDidFinishLaunching? 取决于实现)。

您是否已向大纲视图-reloadData发送消息?这总是对我有用。

于 2010-11-20T02:52:03.140 回答
0

使用 KVO 时,您可以通过向拥有绑定到 NSOutlineView 的属性的对象(很可能是控制器)发送willChangeValueForKey:和来引发更改通知。didChangeValueForKey:这些消息可以从一个awakeFromNib:applicationDidFinishLaunching:处理程序发送,就像reloadData.

如果您在问题中添加(最少的)示例代码,我们可能能够确定这是否可以解决问题,或者是否还有其他需要解决的问题。

于 2010-12-18T16:43:10.810 回答
0

我放弃了绑定这个 NSOutlineView 并改用 NSOutlineViewDataSource 。我怀疑我的代码的某些部分不完全符合 KVO,这使它无法正常工作。

于 2010-11-20T20:02:44.033 回答