TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Aug 2017 |
Maintained by Yan.
HYTableViewSection is for using model to make styles.
pod 'HYTableViewSection'
- (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;
}
HYTableViewSection is available under the MIT license. See the LICENSE file for more info.