Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gcamp/GCRetractableSectionController
Controller that helps the management of UITableViews extendable sections
https://github.com/gcamp/GCRetractableSectionController
Last synced: about 1 month ago
JSON representation
Controller that helps the management of UITableViews extendable sections
- Host: GitHub
- URL: https://github.com/gcamp/GCRetractableSectionController
- Owner: gcamp
- License: other
- Created: 2011-04-22T03:02:28.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2013-02-14T21:55:11.000Z (almost 12 years ago)
- Last Synced: 2024-10-16T12:38:25.668Z (about 2 months ago)
- Language: Objective-C
- Homepage:
- Size: 210 KB
- Stars: 336
- Watchers: 21
- Forks: 54
- Open Issues: 3
-
Metadata Files:
- Readme: README.textile
- License: LICENSE.txt
Awesome Lists containing this project
- awesome - GCRetractableSectionController - Controller that helps the management of UITableViews extendable sections (etc)
- awesome - GCRetractableSectionController - Controller that helps the management of UITableViews extendable sections (etc)
README
h1. GCRetractableSectionController
GCRetractableSectionController is an helper class that let you make easily section of @UITableView@ that detract and contract when tapped.
!http://s3.amazonaws.com/cocoacontrols_production/ios_screens/97/full.png?1303498477!
h2. Usage
(See the demo project included)
h3. Creation and customization
First thing you need to do is subclass @GCRetractableSectionController@ to have your own section controller. (You can also look at @GCArraySectionController@, a drop-in subclass that you can use right away, available in the demo project.)
The basics things you need to overwrite are the following.
@property (nonatomic, copy, readonly) NSString* title;
@property (nonatomic, readonly) NSUInteger contentNumberOfRow;
- (NSString*) titleContentForRow:(NSUInteger) row;The @title@ property represent the title of the section. The @title@ is shown in the main cell when the section controller is closed. The @contentNumberOfRow@ should return the number of rows of _content_ in your section (the title cell is not content). You also overwrite @titleContentForRow:@ to provide the title of your content cells.
See the @GCSimpleSectionController@ example in the demo project.
To react to selection of your content, you should overwrite in your section controller this method.
- (void)didSelectContentCellAtRow:(NSUInteger)row;You can also change have more control on the content of your cells by overwriting the following methods. Look at the @GCCustomSectionController@ in the demo project for more details.
- (UITableViewCell *)cellForRow:(NSUInteger)row;
- (UITableViewCell *)titleCell;
- (UITableViewCell *)contentCellForRow:(NSUInteger)row;h3. UITableView's dataSource usage
When your @GCRetractableSectionController@ is ready, you need to use it in your @UIViewController@.
You initialize your subclass by providing your @UIViewController@. You @UIViewController@ *must* respond to the 'tableView' selector and return a @UITableView@. You'll probably want to save that section controller as an ivar.
YourSectionController* sectionController = [[YourSectionController alloc] initWithViewController:self];@GCRetractableSectionController@ provide simple method for you to use in you @UITableView@ 's dataSource. An example usage follow.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
GCRetractableSectionController* sectionController = /*Your section controller ivar*/;
return sectionController.numberOfRow;
}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
GCRetractableSectionController* sectionController = /*Your section controller ivar*/;
return [sectionController cellForRow:indexPath.row];
}- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
GCRetractableSectionController* sectionController = /*Your section controller ivar*/;
return [sectionController didSelectCellAtRow:indexPath.row];
}