
line.gif
展開后顯示不同cell只需根據(jù)類型判斷
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
SectionModel *model = self.dataSource[indexPath.section];
if (model.cellType == SectionCellType1) {
TableViewCell1 *cell = [tableView dequeueReusableCellWithIdentifier:TABLEVIEWCELL1ID];
return cell;
}else if (model.cellType == SectionCellType2){
TableViewCell2 *cell = [tableView dequeueReusableCellWithIdentifier:TABLEVIEWCELL2ID];
return cell;
}else if (model.cellType == SectionCellType3){
TableViewCell3 *cell = [tableView dequeueReusableCellWithIdentifier:TABLEVIEWCELL3ID];
return cell;
}
TableViewCell1 *cell = [tableView dequeueReusableCellWithIdentifier:TABLEVIEWCELL1ID];
return cell;
}
cell高度自適應(yīng)
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 50;
可通過autolayout或者M(jìn)asonry自適應(yīng)cell高度(前面有文章講解過)
組頭點(diǎn)擊事件代理
- (void)selAnSection:(NSInteger)section {
SectionModel * model = self.dataSource[section];
model.isAn =! model.isAn;
// [self.tableView reloadData];
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:section] withRowAnimation:UITableViewRowAnimationFade];
}
只需控制模型數(shù)據(jù)即可控制UI顯示內(nèi)容,只需刷新對(duì)應(yīng)組即可
代碼地址