Skip to content

Instantly share code, notes, and snippets.

@pier-oliviert
Created December 21, 2010 21:46
Show Gist options
  • Save pier-oliviert/750665 to your computer and use it in GitHub Desktop.
Save pier-oliviert/750665 to your computer and use it in GitHub Desktop.
- (void)loadView {
self.tableView = [[CMTableView alloc] initWithStyle:UITableViewStyleGrouped];
self.tableView.dataSource = self;
self.tableView.delegate = self;
self.view = self.tableView;
}
#pragma mark CMTableView delegate & dataSource
- (NSInteger)numberOfSectionsInTableView:(CMTableView *)tableView {
return 1;
}
- (NSInteger)tableView:(CMTableView *)tv numberOfRowsInSection:(NSInteger)section {
return 2;
}
- (Class)tableView:(CMTableView *)tv viewForRowAtIndexPath:(NSIndexPath *)indexPath {
return [RootView class];
}
- (void)tableView:(CMTableView *)tableView willDisplayView:(RootView *)view forRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.row) {
case 0:
view.text = @"Basic CMText Instances";
break;
default:
view.text = @"Basic CMTextLabel Instances";
break;
}
}
- (void)tableView:(CMTableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
- (void)tableView:(UITableView *)tv didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tv deselectRowAtIndexPath:indexPath animated:YES];
if (indexPath.row == 0) {
BasicCMTextController *ctrl = [[[BasicCMTextController alloc] init] autorelease];
[self.navigationController pushViewController:ctrl
animated:YES];
} else if (indexPath.row == 1) {
BasicCMTextLabelController *ctrl = [[[BasicCMTextLabelController alloc] init] autorelease];
[self.navigationController pushViewController:ctrl
animated:YES];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment