Skip to content

Instantly share code, notes, and snippets.

@Alos
Created September 4, 2010 05:36
Show Gist options
  • Save Alos/564935 to your computer and use it in GitHub Desktop.
Save Alos/564935 to your computer and use it in GitHub Desktop.
@implementation QuestionsTableController : CPObject
{
@outlet CPTableView questionsTableView;
}
- (id)init
{
if (self = [super init])
{
[self initTableView];
}
return self;
}
- (void)initTableView
{
CPLog.trace("Init QuestionsTableView");
var numberCol = [[CPTableColumn alloc] initWithIdentifier:@"Number"];
[[numberCol headerView] setStringValue:"Number"];
[numberCol setWidth:420.0];
[numberCol setMinWidth:50.0];
[numberCol setEditable:YES];
[numberCol setResizingMask:CPTableColumnAutoresizingMask|CPTableColumnUserResizingMask];
[questionsTableView addTableColumn:numberCol];
var col2 = [[CPTableColumn alloc] initWithIdentifier:@"Question"];
[[col2 headerView] setStringValue:@"Question"];
[[col2 headerView] sizeToFit];
[col2 setWidth:[[col2 headerView] frame].size.width];
[questionsTableView addTableColumn:col2];
[questionsTableView setDataSource:self];
[questionsTableView setDelegate:self];
[questionsTableView reloadData];
CPLog.trace("tan tan");
}
@end
@implementation QuestionsTableController (TableDelegatesAndDataSounrce)
/**Delegate methods for the table**/
- (void)doubleClicked:(id)sender{
}
- (id)tableView:(CPTableView)tableView heightOfRow:(int)row
{
return 24;
}
- (int)numberOfRowsInTableView:(CPTableView)tableView
{
return 50;
}
- (id)tableView:(CPTableView)tableView objectValueForTableColumn:(CPTableColumn)tableColumn row:(int)row
{
if ([tableColumn identifier] == "Number"){
return "meh";
}else{
return "moo";
}
}
- (BOOL)tableView:(CPTableView)aTableView shouldSelectRow:(int)rowIndex
{
return YES;
}
- (BOOL)selectionShouldChangeInTableView:(CPTableView)aTableView
{
return YES;
}
@end
@meelash
Copy link

meelash commented Sep 4, 2010

debateListTableView = [[CPTableView alloc] initWithFrame:[debateListScrollView frame]];
[debateListTableView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[debateListScrollView setDocumentView:debateListTableView];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment