Giter Club home page Giter Club logo

modeltableview's Introduction

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.

modeltableview's People

Contributors

rbsgn avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.