展开从数据源加载数据的NSOutlineView的所有项 [英] Expanding all items of a NSOutlineView that loads data from a data source

查看:56
本文介绍了展开从数据源加载数据的NSOutlineView的所有项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我是可可粉开发的新手,所以我想我可能会尝试以错误的方式进行操作,但这是可行的:

First of all I'm new to cocoa development so I suppose I'm probably trying to do this the wrong way, but here goes:

我有一个 NSOutlineView ,它从 NSOutlineViewDataSource 实现中加载数据.我希望所有项目在加载后都可以扩展,但是似乎无法找到数据加载完成后触发的事件,因此我可以发送 [outlineView expandItem:nil expandChildren:YES] .

I have a NSOutlineView which loads the data from a NSOutlineViewDataSource implementation. I want all the items to be expanded after they are loaded, but i can't seem to find an event fired when the data has finished loading, so I can send a [outlineView expandItem: nil expandChildren: YES] to it.

我查看了 NSOutlineViewDelegate 协议,但找不到适合此调用的位置.解决此问题的最佳方法是什么?

I looked into the NSOutlineViewDelegate protocol but I was unable to find a suitable place for this call. What would be the best approach for this problem?

推荐答案

通常,我喜欢在表单内部执行类似的操作-awakeFromNib或任何其他启动回调

Normally I like to do something like this inside form - awakeFromNib or any other startup callbacks

dispatch_async(dispatch_get_main_queue(), ^{
    [self.outlineView expandItem:root expandChildren:YES];
});

这将在运行循环的当前循环结束时将执行块排队,因此,将在所有初始化完成后执行该块.无需设置任何人为延迟.

This will enqueue the execution block at the end of the current cycle in the runloop, thus, it will be executed after all initialization has taken place. There's no need to set any artificial delay.

这篇关于展开从数据源加载数据的NSOutlineView的所有项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆