Latest 0.1.2
Homepage https://github.com/mpan753/ExpandableTableViewDataHelper
License MIT
Platforms ios 9.0
Frameworks UIKit
Authors

ExpandableTableViewDataHelper is an utility API to help easily making an expandable tableview. Providing only three required parameters, one can have a static expandable tableview (by static, the tableview is not editable). Those three parameters include:

  1. the maximum number of level the tableview can expand.
  2. the data source array in each section
  3. the level array list in each section

All those datas are passed through the delegation methods (sort of like the UITableviewDelegate protocol).

This API does not include any UI components as I thought which can provide more flexibility. With a tableview to init it with, one can customize the UI in a freedom way.

An Example Preview

example 1 preview

Getting Started

You can do either pod or manual installation as you like.

Cocoapod Installing

For anyone who is more confortable with cocoapod, just copy the following line into your podfile.

pod ExpandableTableViewDataHelper '~> 0.1.0'

Then run pod install as always.

Manual Installation

For manual installation:

1) Clone this repo locally onto your computer, or press Download ZIP to download the latest master commit.

2) Drag the ExpandableTableViewDataHelper folder into your project.

Added As A Static Library

For anyone who want to add it as a static library:
1) Clone this repo locally onto your computer, or press Download ZIP to download the latest master commit.
2) Select a simulator or an iOS Device as the scheme, and click run. You will have the lib in the Supporting Files folder. You then copy the .a lib from the Finder and copy to your project.

How to use

How to init

Provide a tableview with its designated method, while -init should be no longer used.

- (instancetype)initWithTableView:(UITableView *)tableView;

For example, you have a UIViewController, which contains a UITableView as its view’s subview, then you instantiate your data manager as follows:

ExpandableTableViewDataHelper *dataManager = [[ExpandableTableViewDataHelper alloc] initWithTableView:yourTableView];

Set the delegate

Once you have a ExpandableTableViewDataHelper instance, you should set its delegate immediately:

dataManager.delegate = someDelegate;

Now you should fill in the delegation methods as it asks:

- (NSArray *)dataArrayInSection:(NSInteger)section;
- (NSInteger)numberOfLevels;
- (NSArray *)levelArraysInSection:(NSInteger)section;

How to expand the tableview

When tableView:didSelectRowAtIndexPath:, you simply call this method to do the expanding.

- (void)didSelectRowAtIndexPath:(NSIndexPath *)indexPath;

Authors

  • Meng PanInitial workmpan753

License

This project is licensed under the MIT License – see the LICENSE.md file for details

Latest podspec

{
    "name": "ExpandableTableViewDataHelper",
    "version": "0.1.2",
    "summary": "ExpandableTableViewDataHelper serves as a tree data manager to orgnize the data of its expandable tableview.",
    "homepage": "https://github.com/mpan753/ExpandableTableViewDataHelper",
    "license": {
        "type": "MIT",
        "file": "MIT License"
    },
    "authors": {
        "mpan753": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/mpan753/ExpandableTableViewDataHelper.git",
        "tag": "0.1.2"
    },
    "source_files": "ExpandableTableViewDataHelper/**/*.{h,m}",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This