【问题标题】:How to dynamically update an NSTreeController and NSOutlineView?如何动态更新 NSTreeController 和 NSOutlineView?
【发布时间】:2015-11-12 23:55:51
【问题描述】:

outlineViewItem 展开时 -

 (void) outlineViewItemDidExpand:(NSNotification *)notification

-,我能够成功地将对象添加到 TreeController(日志语句将新添加的对象显示在层次结构的正确位置),但 OutlineView/UI 没有更新以反映该插入。

没用,我用过

  • [self.outlineView reloadItem:nil reloadChildren:YES],

  • [self.outlineView reloadData],甚至是

  • [self.outlineView setHidden:YES] 然后
    [self.outlineView setHidden:NO]

尝试强制重新加载结构。

这一切都是在 Objective-C 中以编程方式完成的。

【问题讨论】:

  • 你使用绑定还是只使用NSOutlineViewDataSource-protocol 方法?
  • 我对值、大纲视图内容和索引路径 (NSOutlineView) 以及内容数组/控制器内容 (NSTreeView) 使用绑定。我使用的唯一代表是: - (void) outlineViewItemDidExpand:(NSNotification *)notification

标签: objective-c macos cocoa nsoutlineview nstreecontroller


【解决方案1】:

6 小时后,我明白了。

我需要更新 NSTreeController 缓存,这是通过rearrangeObjects 方法实现的。

所以我的问题的答案是:

[self.cloudDirectoryTreeController rearrangeObjects];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-20
    • 1970-01-01
    • 1970-01-01
    • 2012-04-16
    • 1970-01-01
    相关资源
    最近更新 更多