TableView列表展開不同cell

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)組即可
代碼地址

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容