Skip to content

Instantly share code, notes, and snippets.

@jakemarsh
Created October 16, 2011 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakemarsh/1290401 to your computer and use it in GitHub Desktop.
Save jakemarsh/1290401 to your computer and use it in GitHub Desktop.
Is This Cool? Or No?
- (void) viewDidLoad {
[super viewDidLoad];
self.airplaneModeSwitch = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease];
[self addSection:^(JMStaticContentTableViewSection *section, NSUInteger sectionIndex) {
[section addCell:^(JMStaticContentTableViewCell *staticContentCell, UITableViewCell *cell, NSIndexPath *indexPath) {
staticContentCell.reuseIdentifier = @"UIControlCell";
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.textLabel.text = NSLocalizedString(@"Airplane Mode", @"Airplane Mode");
cell.imageView.image = [UIImage imageNamed:@"AirplaneMode"];
cell.accessoryView = self.airplaneModeSwitch;
}];
[section addCell:^(JMStaticContentTableViewCell *staticContentCell, UITableViewCell *cell, NSIndexPath *indexPath) {
staticContentCell.cellStyle = UITableViewCellStyleValue1;
staticContentCell.reuseIdentifier = @"DetailTextCell";
cell.textLabel.text = NSLocalizedString(@"Wi-Fi", @"Wi-Fi");
cell.detailTextLabel.text = NSLocalizedString(@"iamtheinternet", @"iamtheinternet");
} whenSelected:^(NSIndexPath *indexPath) {
WifiViewController *vc = [[WifiViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
[vc release];
}];
[section addCell:^(JMStaticContentTableViewCell *staticContentCell, UITableViewCell *cell, NSIndexPath *indexPath) {
cell.textLabel.text = NSLocalizedString(@"Notifications", @"Notifications");
cell.imageView.image = [UIImage imageNamed:@"Notifications"];
} whenSelected:^(NSIndexPath *indexPath) {
//TODO
}];
[section addCell:^(JMStaticContentTableViewCell *staticContentCell, UITableViewCell *cell, NSIndexPath *indexPath) {
staticContentCell.cellStyle = UITableViewCellStyleValue1;
staticContentCell.reuseIdentifier = @"DetailTextCell";
cell.textLabel.text = NSLocalizedString(@"Location Services", @"Location Services");
cell.detailTextLabel.text = NSLocalizedString(@"On", @"On");
} whenSelected:^(NSIndexPath *indexPath) {
//TODO
}];
}];
@gotosleep
Copy link

It is cool! I actually created something quite similar: https://github.com/gotosleep/JATableModel

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