I am making an NSTableView programmatically but for some reason no matter what I do, I cannot make the darn headerView show up. It is imperative that I do this programmatically and not use the IB because I am actually developing this widget in an IDE called clozure cl which is a lisp ide that includes a cocoa bridge. Originally I thought this problem might have been caused by my development environement but I just created an example in Xcode using only objective C and it seems that the problem persists. What I do is pretty straightforward:
I make a window in the IB and in its awkefromnib methods I create and setup a table-view here is the code:
- (void)awakeFromNib {
mydatasource *data = [[mydatasource alloc] init];
NSTableColumn *column = [[NSTableColumn alloc] initWithIdentifier:@"id"];
NSTableView *table = [[NSTableView alloc] initWithFrame: [[self
contentView]frame]];
[table setDataSource:data];
[table addTableColumn:column];
[table addTableColumn:column];
[[self contentView] addSubview:table];
}
Here is the code for my data source object:
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{
printf("NUM ROwS");
return 4;
}
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
printf("THE OTHER ONE");
return @"OKAY";
}
With this code I get a window with two colums and four rows and each cell displaying the string "OKAY", this is all fine and good except the table has no header. This might make sense except when I look at the tables header method, it has an initialized header with a frame whose values make sense. I am just wondering why I do not see it. Is there some special kind of magic I need to do so the header will display? I cannot seem to find any clues in the documentation. Once again it is imperative for the lisp ide that this be done programmatically so it would not be helpful no suggest using the IB which I know will have a working headerView. Thanks a lot.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…