繁体   English   中英

NSTableView-如何识别NSTableCellView中图像的名称?

[英]NSTableView - how can I identify the name of the image in an NSTableCellView?

我有一个具有简单的NSTextField和NSImageCell的NSTableCellView。

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

但是,当我在运行时加载图像时,相同的语句导致(空)。

任何帮助,将不胜感激。 请注意,这是针对OS / X的-但是,为了将来使用,我也希望iOS的想法。 谢谢

我认为您应该使用cell.imageView.image.name而不是记录cell.image.name

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM