无法以编程方式在基于视图的NSTablveView cellView中绑定NSImageView

时间:2016-12-17 05:58:47

标签: nstableview cocoa-bindings

我有一个基于视图的NSTableView,它是一个包含自定义CellView的单列,包含大约十二个文本字段和一个NSImageView。

-(NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
    ComboTableCellView* view = [tableView makeViewWithIdentifier:[tableColumn identifier] owner:nil];

    // I bind the text fields with:

    [[view nameView] bind:NSValueBinding toObject:view withKeyPath:@"objectValue.name" options:nil];

    // I bind the NSImageView with:

    NSMutableDictionary* statusOptions = [[[NSMutableDictionary alloc] initWithCapacity:0] autorelease];
    [options setObject:kStatusIconTransformerName forKey:NSValueTransformerNameBindingOption];
    [[view statusView] bind:NSValueBinding toObject:view withKeyPath:@"objectValue.status" options:statusOptions];

    return (view);
}

我的变换器获取“状态”,这是一个NSNumber并返回NSImage,因为状态将是1到4之间的数字。这适用于带有NSImage列的基于单元的NSTableView。

但是,在基于视图的NSTableView中,我得到了:

无法从(ComboTableCellView 0x6180001e3e00)中删除关键路径“objectValue.status”的观察者(NSAutounbinderObservance 0x600000028ac0),这很可能是因为在没有发送适当的KVO通知的情况下,键“objectValue”的值已更改。检查ComboTableCellView类的KVO兼容性。

如何正确绑定在基于视图的NStableView中用作行/单元视图的可重用视图中的NSImageView?

0 个答案:

没有答案
相关问题