Latest 0.0.5
Homepage https://github.com/minerany/MAYCollectionViewDataSource
License MIT
Platforms ios 8.0
Authors

Installation

pod 'MAYCollectionViewDataSource', :git => 'https://github.com/minerany/MAYCollectionViewDataSource.git'

Usage

For example create UITableView dataSource

Import header file:

#import "MAYCollectionViewDataSource+UITableView.h"

Create a MAYCollectionViewDataSource instance and configure it:

MAYCollectionViewDataSource *dataSource = [MAYCollectionViewDataSource new];
MAYCollectionViewCellSource *cellSource = [MAYCollectionViewCellSource sourceWithIdentifier:@"cell"];
cellSource.data = @" hello miner";
[cellSource setTarget:self configSelector:@selector(__configCustomCell:cellSource:)];
[cellSource setTarget:self actionSelector:@selector(__performAction:cellSource:)];
[dataSource addCellSource:@[cellSource]];

Use MAYDeclareConfigCellSelector and MAYDeclareCellActionSelector declare configSelector and actionSelector in interface extension

MAYDeclareConfigCellSelector(__configCustomCell, UITableViewCell *, MAYCollectionViewCellSource*)
MAYDeclareCellActionSelector(__performAction, UITableViewCell *, MAYCollectionViewCellSource*)

Then implementation config and action method

- (void)__configCustomCell:(UITableViewCell *)cell cellSource:(MAYCollectionViewCellSource *)cellSource {
  cell.textLabel.text = cellSource.data;
}

- (void)__performAction:(UITableViewCell *)cell cellSource:(MAYCollectionViewCellSource *)cellSource {
  NSLog(@"%@",cellSource.data);
}

And UITableView dataSource configuration done!

If you want to implement UITableView scrollviewDidScroll delegate method, you can set 

dataSource.interceptedTableViewDelegate = self;

In this delegate, you can implemente UITableViewDelegate delegate method that you want.

MAYCollectionViewDataSource also support self-sizing TableViewCell, if you set

tableView.rowHeight = UITableViewCellAutomaticHeight;

More Detail you can see in ExampleViewController…
   

Latest podspec

{
    "name": "MAYCollectionViewDataSource",
    "version": "0.0.5",
    "summary": "MAYCollectionViewDataSource can quickly construct datasource for collection view.",
    "description": "UITableView UICollectionView DataSource Delegate MAYCollectionViewDataSource CollectionViewDataSource",
    "homepage": "https://github.com/minerany/MAYCollectionViewDataSource",
    "license": "MIT",
    "authors": {
        "minerany": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/minerany/MAYCollectionViewDataSource.git",
        "tag": "0.0.5"
    },
    "exclude_files": "Classes/Exclude",
    "source_files": [
        "MAYCollectionViewDataSource/Classes/*.{h,m}",
        "MAYCollectionViewDataSource/Classes/Private/*.{h,m}",
        "Classes/Exclude"
    ],
    "public_header_files": "MAYCollectionViewDataSource/Classes/*.h"
}

Pin It on Pinterest

Share This