这是怎么回事……
- (NSUInteger)sourceList:(PXSourceList*)sourceList numberOfChildrenOfItem:(ID)item; { if (item == nil) { // item is nil so it's part of the very top hIErarchy. // return how many sections we need. return 2; } else { if ([item class] == [TSfileSystemItem class] ) { return [item numberOfChildren]; // if item isn't nil and it's a TSfileSystemItem,then return it's children. } if ([item class] == [TSWorkspaceItem class]) { return 2; // i don't kNow,random items. } else { NSLog(@"this is a special object."); } }}- (BOol)sourceList:(PXSourceList *)aSourceList isItemExpandable:(ID)item { if (item == nil) { return YES; } else { // if the number of children of the item is -1 BOol gibberhook = ([item numberOfChildren] != -1); return gibberhook; }}-(ID)sourceList:(PXSourceList *)aSourceList child:(NSUInteger)index ofItem:(ID)item { if (item == nil) { return [TSfileSystemItem rootItem]; } else { return [(TSfileSystemItem *)item childAtIndex:index]; }}- (ID)sourceList:(PXSourceList *)aSourceList objectValueForItem:(ID)item { if (item == nil) { return @"/"; } else { if (item == [TSfileSystemItem rootItem]) { return PROJECT_fileS; } else { return [item relativePath]; } }}
神秘的TSfileSystemItem来自:https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/OutlineView/Articles/UsingOutlineDataSource.html.
所有这一切都没问题,除了我想将我的源列表分成多个部分(根单元格).一个显示文件层次结构(检查),另一个显示…
那么另一个将包含一个NSMutableArray,我从其他部分添加项目.听起来很复杂?更好的解释.单击具有文件层次结构的部分中的项目,并将其添加到其他部分.
我试图在Apple的文档的帮助下解决这个问题,但我仍然找不到一个简单,有效,稳定的方法来制作我上面提到的功能的两个部分.如果只是像为UItableVIEw配置数据源一样简单…
任何人都可以帮助我吗?
解决方法 当调用childrenForItem委托方法并且项目为nil时,它会请求树的根.如果返回并且数组,则树将为该数组中的每个元素提供根节点.- (NSArray *)childrenForItem:(ID)item { if (item == nil) { return [self.roottreeNode childNodes]; } else { return [item childNodes]; }}总结
以上是内存溢出为你收集整理的objective-c – 动态NSOutlineView数据源全部内容,希望文章能够帮你解决objective-c – 动态NSOutlineView数据源所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)