0
我在Xcode中創建了一個NSOutlineView(Sourcelist),給它一個插座,並讓我的類實現NSOutlineViewDataSource。然後我[outlineview setDataSource:]
,我看到它創建了我的數組中的項目數的單元格,但它們都是空白的。NSOutlineView數據源
sub1 = [NSArray arrayWithObjects:@"General Data",@"Most Played", @"Misc",@"Log", nil];
sub2 = [NSArray arrayWithObjects:@"General Data", @"Most Played", @"Misc",@"Log", nil];
items = [NSArray arrayWithObjects:sub1,sub2,nil];
[outlin setDataSource:self];
[outlin reloadData];
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{
return [self outlineView:outlineView numberOfChildrenOfItem:item] != 0;
}
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
{
if (item)
if ([item isKindOfClass:[NSArray class]])
return [item count];
else
return 0;
else
return [items count];
}
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
{
if (item) {
return [item objectAtIndex:index];
}
else
return [items objectAtIndex:index];
}
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)theColumn byItem:(id)item
{
if (item) {
if ([item isKindOfClass:[NSArray class]])
return @"YES"; // Return name for this node
else
return item;
}
else
return @"List Root";
}
一切似乎是按順序,這是一種作品,除了所有的文字是空白的。它創建了所有的根項目,並且只是沒有文本。
你檢查,在Interface Builder您綁定的大綱視圖中的細胞? – 2012-03-10 03:02:25