【发布时间】:2013-09-16 15:41:30
【问题描述】:
我有带有 3 个标签的 NSTableView。 现在,我想在每个标签中都有一张图片,我该怎么办? 我必须使用带有位置的 NSImage,所以?
NSImage *theImage; theImage = [NSImage imageNamed@"myImage.png"];
【问题讨论】:
-
这里tab的意思是列请注明??
标签: nstableview nsimage
我有带有 3 个标签的 NSTableView。 现在,我想在每个标签中都有一张图片,我该怎么办? 我必须使用带有位置的 NSImage,所以?
NSImage *theImage; theImage = [NSImage imageNamed@"myImage.png"];
【问题讨论】:
标签: nstableview nsimage
你可以这样做: 在代码中创建一个具有属性和合成的 NSMutableArray
头文件:
@property(读写,保留)NSMutableArray *imageArray
实现文件:
@synthesize imageArray
无论您想将图像添加到数组中的任何位置,都可以这样做:
NSMutableDictionary *imageDict = [NSMutableDictionary dictionary];
[imageDict setObject:[NSImage imageNamed:@"ABC"] forKey:@"image1"];
[imageDict setObject:[NSImage imageNamed:@"XYZ"] forKey:@"image2"];
[imageDict setObject:[NSImage imageNamed:@"XYZ"] forKey:@"image3"];
[imageArray imageDict];
[self setImageArray:imageArray];
在 XIb 中获取数组控制器,将数组控制器绑定到 imageArray 数组,将表列与具有给定键路径的数组控制器绑定(这里的键路径是 image1、image2 和 image3)。
还有一个东西是没有扩展名的图像名称。在表格视图单元格上拖放图像单元格
【讨论】: