gpt4 book ai didi

macos - NSTableView错误: preparedCellAtColumn:row: was Called

转载 作者:行者123 更新时间:2023-12-03 17:22:10 24 4
gpt4 key购买 nike

我遇到一个问题,当您在 NSOutlineView 中选择顶级对象时,会生成一条错误消息:

"View Based NSTableView error: preparedCellAtColumn:row: was called. Please log a bug with the backtrace from this log, or stop using the method."

我正在使用的 NSOutlineView 设置为基于 View 。我不知道为什么要调用 preparedCellAtColumn 方法。我添加了该方法并放置了一个断点来尝试跟踪调用该方法的内容,但是当 XCode 触发此异常时,它看起来会阻止该方法的执行。

编辑 - 委托(delegate)和 DateSource 方法

- (BOOL) itemAtIndexIsHeader: (NSInteger) index
{
return [self isHeader: [_projectPane itemAtRow: index]];
}
- (BOOL) isHeader: (id) item
{
return [item isKindOfClass: [Folder class]];
}
- (BOOL) outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item
{
return NO;
}
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
{
//item is nil when the outline view wants to inquire for root level items
if (item == nil)
return [[[PMDataManager sharedManager] allFolders] objectAtIndex: index];
else{
Folder *folder = (Folder *) item;
return [[[folder projects] allObjects] objectAtIndex: index];
}
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{
return [self isHeader: item];
}
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
{
if (item == nil) { //item is nil when the outline view wants to inquire for root level items
return [[[PMDataManager sharedManager] allFolders] count];
}
else if ([self isHeader: item]) {
Folder *folder = (Folder *) item;
return [[[folder projects] allObjects] count];
}

return 0;
}
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item {
if ([self isHeader: item]){
PMProjectHeaderCell *cell = [outlineView makeViewWithIdentifier:@"HeaderCell" owner:self];
Folder *folder = (Folder *) item;
[[cell headerText] setStringValue: [folder name]];

return cell;
}
else{
PMProjectCell *cell = [outlineView makeViewWithIdentifier:@"ProjectCell" owner:self];
Project *project = (Project *) item;
[[cell projectNameTextField] setStringValue: [project name]];
return cell;
}

return nil;
}
- (void) outlineViewSelectionDidChange:(NSNotification *)notification
{
selectedProjectIndex = [_projectPane selectedRow];
[self reloadRightPane];
[self refresh: nil];
}

最佳答案

验证您的表格 View 内容模式是否与您尝试使用的数据源/委托(delegate)方法匹配。

如果您尝试使用基于单元格的数据源,请验证表格 View 内容模式是否为“基于单元格”。基于 View 也是如此。

关于macos - NSTableView错误: preparedCellAtColumn:row: was Called,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20817643/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com