Latest 0.0.4
Homepage https://github.com/mingway1991/MWTableView
License MIT
Platforms ios 7.0
Frameworks UIKit
Authors

Build Status
Version
Platform
Support

安装

CocoaPods

第一步

pod 'MWTableView'

如果想试用最新版,默认拉取master分支

pod 'MWHUD', :git => 'https://github.com/mingway1991/MWTableView.git'

第二步

pod install

使用方法

使用的viewController需要实现两个协议MWTableViewMakerDataSource, MWTableViewMakerDelegate

@property (nonatomic, strong) MWTableViewMaker *tableViewMaker;

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableViewMaker = [[MWTableViewMaker alloc] initWithFrame:self.view.bounds contentInsets:UIEdgeInsetsZero tableViewStyle:UITableViewStyleGrouped];
    self.tableViewMaker.dataSource = self;
    self.tableViewMaker.delegate = self;
    [self.view addSubview:self.tableViewMaker.tableView];
}

#pragma mark -
#pragma mark MWTableViewDataSourceMaker
- (MWDataSource *)mwTableViewMakeDataSourceForMe {
    //组装dataSource
    MWDataSource *dataSource = [[MWDataSource alloc] init];
    NSMutableArray *sections = [NSMutableArray array];
    //组装section
    MWSectionEntity *demoSection = [[MWSectionEntity alloc] init];
    //组装header
    MWHeaderFooterViewEntity *demoHeader = [[MWHeaderFooterViewEntity alloc] init];
    demoHeader.identifier = @"demoHeader";
    demoHeader.viewClassName = NSStringFromClass([UITableViewHeaderFooterView class]);
    demoHeader.viewHeight = 30.f;
    demoSection.header = demoHeader;
    //添加cell
    MWTableViewCellEntity *demoCell = [[MWTableViewCellEntity alloc] init];
    demoCell.identifier = @"demoCell";
    demoCell.cellClassName = NSStringFromClass([UITableViewCell class]);
    demoCell.cellHeight = 60.f;
    demoSection.cells = @[demoCell];
    //组装footer
    MWHeaderFooterViewEntity *demoFooter = [[MWHeaderFooterViewEntity alloc] init];
    demoFooter.identifier = @"demoFooter";
    demoFooter.viewClassName = NSStringFromClass([UITableViewHeaderFooterView class]);
    demoFooter.viewHeight = 10.f;
    demoSection.footer = demoFooter;

    [sections addObject:demoSection];
    dataSource.sections = sections;
    return dataSource;
}

//可选实现,更新cell
- (void)updateCellWithTableViewCell:(UITableViewCell *)cell 
              indexPath:(NSIndexPath *)indexPath 
             cellEntity:(MWTableViewCellEntity *)cellEntity {
    if ([cellEntity.identifier isEqualToString:@"demoCell"]) {
        //update cell
    } 
}

//可选实现,更新header
- (void)updateHeaderWithHeaderView:(UITableViewHeaderFooterView *)headerView 
               section:(NSInteger)section 
                      headerEntity:(MWHeaderFooterViewEntity *)headerEntity {
   if ([headerEntity.identifier isEqualToString:@"demoHeader"]) {
        //update header
    } 
}

//可选实现,更新footer
- (void)updateFooterWithFooterView:(UITableViewHeaderFooterView *)footerView
                           section:(NSInteger)section
                      footerEntity:(MWHeaderFooterViewEntity *)footerEntity {
    if ([footerEntity.identifier isEqualToString:@"demoFooter"]) {
        //update header
    } 
}

#pragma mark -
#pragma mark MWTableViewMakerDelegate
- (void)didSelectForMWTableView:(UITableView *)tableView
                      indexPath:(NSIndexPath *)indexPath
                     cellEntity:(MWTableViewCellEntity *)cellEntity {
    //处理选中cell事件
}

Latest podspec

{
    "name": "MWTableView",
    "version": "0.0.4",
    "summary": "MWTableView",
    "description": "MWTableView description",
    "homepage": "https://github.com/mingway1991/MWTableView",
    "license": "MIT",
    "authors": {
        "shimingwei": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mingway1991/MWTableView.git",
        "tag": "0.0.4"
    },
    "source_files": "MWTableView/**/*.{h,m}",
    "platforms": {
        "ios": "7.0"
    },
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This