簡體   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