I want to create a tableview in code, not IB, but it will not display. Here is my code:
- (void)createTableView{
_tableView = [[NSTableView alloc]initWithFrame:NSMakeRect(0, 0, 700, 300)];
[_tableView setBackgroundColor:[NSColor cyanColor]];
[_tableView setDelegate:self];
[_tableView setDataSource:self];
[self addSubview:_tableView];
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView{
return 10;
}
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row{
NSButtonCell *cell = [[[NSButtonCell alloc] init] autorelease];
[cell setAllowsMixedState:YES];
[(NSButtonCell *)cell setButtonType:NSSwitchButton];
[cell setTitle:@"Test"];
return cell;
}
When I debugged, I see it doesn't run objectValueForTableColumn:.
I don't know why.