我已经读了很多关于这一点,但我不能得到它的工作,我有一个定制的NSCell与此代码的NSView中的NSCell
#import "ServiceTableCell.h"
@implementation ServiceTableCell
-(void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
NSLog(@"I'm being called");
NSView *newview = [[NSView alloc] initWithFrame:cellFrame];
NSImage *image = [NSImage imageNamed:@"bg.png"];
NSRect imagesize;
NSImageView *IMV = [[NSImageView alloc] initWithFrame:imagesize];
[IMV setImage:image];
[newview addSubview:IMV];
[controlView addSubview:newview];
}
这我NSTableView的数据源:
- (long)numberOfRowsInTableView:(NSTableView *)tableView {
return 3;
}
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(long)row
{
return [[ServiceTableCell alloc] initTextCell:@"dd"];
}
据我所知,drawwithframe ...被调用时,单元格初始化,但它永远不会被调用,所以,我错过了什么?
所以,现在的问题是,如何创建自定义单元格并将其设置为我的列? – 2011-05-22 23:19:50