iOS-TableView中cell的顯示與隱藏

項(xiàng)目中,總會(huì)遇到各種鬼需求,比如cell的顯示隱藏就算吧,好好的數(shù)據(jù)直接展示就得了唄,非得隱藏起來(lái),我就納悶了,隱藏了,還顯示嘎哈???畢竟就是個(gè)擼代碼的,咋也得搞出來(lái)。

效果圖就是這樣:

黑色的為每組頭視圖,點(diǎn)擊展開隱藏的cell,再點(diǎn)擊收縮隱藏。
黑色的為每組頭視圖,點(diǎn)擊展開隱藏的cell,再點(diǎn)擊收縮隱藏。

黑色的為每組頭視圖,點(diǎn)擊展開隱藏的cell,再點(diǎn)擊收縮隱藏。
各種設(shè)置,已經(jīng)封裝起來(lái)了,使用的時(shí)候,直接遵守各個(gè)協(xié)議就可以了。


#pragma mark - YUFoldingTableViewDelegate / required
- (PackUpTableViewSectionHeaderArrowPosition)perferedArrowPositionForYUFoldingTableView:(PackUpTableView *)yuTableView {
    return self.arrowPosition ? :PackUpTableViewSectionHeaderArrowPositionRight;
}

- (NSInteger )numberOfSectionForPackUpTableView:(PackUpTableView *)tableView{
    return 4;
}

- (NSInteger )packUpTableView:(PackUpTableView *)tableView numberOfRowsInSection:(NSInteger )section {
    return 3;
}

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

- (CGFloat )packUpTableView:(PackUpTableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 50;
}

- (NSString *)packUpTableView:(PackUpTableView *)tableView titleForHeaderInSection:(NSInteger)section {
    return self.titleArray[section];
}

- (UITableViewCell *)packUpTableView:(PackUpTableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellID = @"cellID";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellID];
    }
        cell.textLabel.text = self.valueArray[indexPath.row];
        cell.textLabel.textColor = [UIColor redColor];
        cell.detailTextLabel.text = self.valueDetailArray[indexPath.row];
        cell.detailTextLabel.textColor = [UIColor redColor];
        return cell;
}

- (void )packUpTableView:(PackUpTableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

#pragma mark - YUFoldingTableViewDelegate / optional
- (NSString *)packUpTableView:(PackUpTableView *)tableView descriptionForHeaderInSection:(NSInteger )section {
    return self.titleDetailArray[section];
}

以上就是主要的幾個(gè)協(xié)議方式,基本也就這些,寫上了,請(qǐng)求數(shù)據(jù),再一賦值就OK了。

鏈接:https://github.com/Baiyongyu/PackUpTableView.git

最后編輯于
?著作權(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)容