我有一个NSTableCellView,它有一个简单的NSTextField和一个NSImageCell。
NSTableCellView *cell = [tableView makeViewWithIdentifier:@"List" owner:self];
cell.textField.stringValue = name;
cell.imageView.image = [NSImage imageNamed:@"image1.png"]; (or image 2,3, etc)
稍后,当我从表中选择一行时,我希望能够看到图像的名称。如果我从IB预加载图像,我可以使用:
NSTableColumn *column = [self.tableView tableColumnWithIdentifier:@"List"];
NSCell *cell = [column dataCellForRow:row];
NSLog(@"TableView image:%@",cell.image.name);
这显示IB名称-例如。
NSEveryWhere
但当我在运行时加载图像时,相同的语句会导致(null)。
如有任何帮助,将不胜感激。请注意,这是针对OS/X的-但是,为了将来的使用,我也会感谢iOS的想法。谢谢