Latest 1.0.3
Homepage https://github.com/yansaid/HYTableViewSection
License MIT
Platforms ios 7.0, requires ARC
Authors

HYTableViewSection is for using model to make styles.

Install

pod ‘HYTableViewSection’

Usage

- (void)reload {
    int i = 0;
    while (i < 5) {
        i++;
        HYTableViewRow *row = [HYTableViewRow row:@{@"title":@"style1"}];
        row.identifier = @"style1";
        row.heightBlock = ^CGFloat{
            return 100;
        };
        [self.tableView.hy_section addRowModel:row atSection:0];
    }

    HYTableViewRow *row1 = [HYTableViewRow row:@{@"title":@"style2"}];
    row1.identifier = @"style2";
    row1.heightBlock = ^CGFloat{
        return 100;
    };
    [self.tableView.hy_section addRowModel:row1 atSection:1];

    HYTableViewRow *row2 = [HYTableViewRow row:nil];
    row2.identifier = @"style2";
    [self.tableView.hy_section addRowModel:row2 atSection:2];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    HYTableViewRow *row = [self.tableView.hy_section rowAtIndexPath:indexPath];
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:row.identifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:row.identifier];
    }
    cell.textLabel.text = row.model[@"title"];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    HYTableViewRow *row = [self.tableView.hy_section rowAtIndexPath:indexPath];
    return row.height;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [self.tableView.hy_section numberOfRowsInSection:section];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return [self.tableView.hy_section numberOfSections];
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 50;
}

License

HYTableViewSection is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "HYTableViewSection",
    "version": "1.0.3",
    "summary": "HYTableViewSection for UITableView",
    "description": "HYTableViewSection is for using models to make styles.",
    "homepage": "https://github.com/yansaid/HYTableViewSection",
    "license": "MIT",
    "authors": {
        "Yan": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/yansaid/HYTableViewSection.git",
        "tag": "1.0.3"
    },
    "source_files": [
        "HYTableViewSection",
        "HYTableViewSection/**/*.{h,m}"
    ],
    "exclude_files": "Classes/Exclude",
    "requires_arc": true
}

Pin It on Pinterest

Share This