0

在 Apple 的 Mail 应用程序中,在左侧的大纲视图中,收件箱或文件夹以层次结构显示,但文件夹或电子邮件中的电子邮件根本不显示。

我想重现此功能。

我有一个连接到树控制器的大纲视图。对象(节点)被添加到树控制器并显示在大纲视图中。如何防止某些对象出现?具体来说,我有包含自定义对象实例的文件夹节点。就像在 Mail.app 中一样,我只想在大纲视图中显示文件夹,并将自定义对象显示在另一个视图中。

根据要求提供一些控制器代码;在这里,我将节点添加到在大纲视图中选择的 folderNode:

indexPath = [treeController selectionIndexPath];
indexPath = [indexPath indexPathByAddingIndex:[[[[treeController selectedObjects] objectAtIndex:0] children] count]];//want to insert the new node at the end of the folder node's array of children
    ...
[treeController insertObject:customObjectNode atArrangedObjectIndexPath:indexPath];
NSLog(@"No. of items selected in tree controller/outline view is %i",[[treeController selectedNodes] count]); //if the folderNode is a leaf, this gives 0, i.e. no selection

// if the folderNode is not a leaf, the added child automatically becomes selected by NSOutlineView. In that case I keep its parent selected (the folder) so the next customObjectNode can be added
[self selectParentFromSelection];//however this method will then do nothing because at this point nothing is selected. Now this whole paragraph of code cannot be repeated because nothing is selected so the first line of code doesn't work.
4

1 回答 1

0

您是否使用任何其他需要继续处理孩子的树控制器?

如果没有,只需将文件夹节点返回YES-isLeaf(并且对于 childNodes 键为 nil)。

于 2012-05-19T16:40:41.357 回答