GitHub - rbsgn/ModelTableView: UITableViewController based on a section/cell model | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

rbsgn/ModelTableView

Repository files navigation

YXModelTableViews

Using this mini-framework you can simpify creation of settings-like/card-like table views. All you need is to subclass your view controller from YXModelTableViewController and set its sections with code like the following:

YXSection * sectionA = [[YXSection alloc] initWithHeader:@"Section A" footer:nil];

// Just a cell with a title and switch control at the right. You provice two
// callbacks: the first returns an initial value and the second is called
// when user chcnges the switch
[sectionA addCell:[YXSwitchCell cellWithReuseIdentifier:@"cell0" 
											  withTitle:@"BOOM!" 
										   withDelegate:self 
									 initialValueGetter:@selector(cell0InitialValue:) 
										  changeHandler:@selector(cell0:changedValue:)]];
										
// A cell with title (and possible a detail/value text) with a disclosure indicator
// at the right. You provide a callback which is called after the cell was tapped.
[sectionA addCell:[YXDisclosureCell cellWithReuseIdentifier:@"cell1" 
												  withTitle:@"Advanced" 
											   withDelegate:self 
												   selector:@selector(cell1Tapped:)]];
												
// This cell looks like YXSwitchCell but it is provided with object/key
// information. So it takes an initial value itself and updates it
// when user changes the value.
[sectionA addCell:[YXKVOSwitchCell cellWithReuseIdentifier:@"kvoCell" 
			withTitle:@"KVO Bound Cell" 
		   withObject:defaults 
			  withKey:@"myPreferenceKey"]];
												


YXSection * sectionB = [[YXSection alloc] initWithHeader:nil footer:@"Section B"];
[sectionB addCell:[YXSwitchCell cellWithReuseIdentifier:@"cell2" 
											  withTitle:@"BAH!1" 
										   withDelegate:self 
									 initialValueGetter:@selector(cell2InitialValue:) 
										  changeHandler:@selector(cell2:changedValue:)]];

YXSection * sectionC = [[YXSection alloc] initWithHeader:@"Section C before" footer:@"Section C after"];

// A cell which looks like a button (its label is blue and centered).
[sectionC addCell:[YXButtonCell cellWithReuseIdentifier:@"buttonCell" 
											  withTitle:@"Button"
										   withDelegate:self 
											   selector:@selector(buttonCellTapped:)]];


[self setSections:[NSArray arrayWithObjects:sectionA, sectionB, sectionC, nil]];

After this you usually better to call [self.tableView reloadData] since setSections: doesn't do that.

About

UITableViewController based on a section/cell model

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.