美文网首页
iOS-TableView中cell的显示与隐藏

iOS-TableView中cell的显示与隐藏

作者: 宇玄丶 | 来源:发表于2017-04-19 10:19 被阅读0次

项目中,总会遇到各种鬼需求,比如cell的显示隐藏就算吧,好好的数据直接展示就得了呗,非得隐藏起来,我就纳闷了,隐藏了,还显示嘎哈啊?毕竟就是个撸代码的,咋也得搞出来。

效果图就是这样:

黑色的为每组头视图,点击展开隐藏的cell,再点击收缩隐藏。黑色的为每组头视图,点击展开隐藏的cell,再点击收缩隐藏。

黑色的为每组头视图,点击展开隐藏的cell,再点击收缩隐藏。
各种设置,已经封装起来了,使用的时候,直接遵守各个协议就可以了。


#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];
}

以上就是主要的几个协议方式,基本也就这些,写上了,请求数据,再一赋值就OK了。

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

相关文章

  • iOS-TableView中cell的显示与隐藏

    项目中,总会遇到各种鬼需求,比如cell的显示隐藏就算吧,好好的数据直接展示就得了呗,非得隐藏起来,我就纳闷了,隐...

  • iOS 多种cell的隐藏与显示

    当tableView有多种视图的时候。 我们应该建立很多cell来匹配他。 而不是建立一个cell 去控制他的隐藏...

  • tableview性能优化的一些小点

    1.Cell重用 2. 定义一种(尽量少)类型的Cell及善用hidden隐藏(显示)subviews 3. 提前...

  • UItableViewCell的显示与隐藏

    最近有一个需求 就是对于tableviewCell的显示与隐藏的处理.就是点击cell有部分文字展示出来,右侧的箭...

  • iOS 表单处理心得&静态cell动态cell混用

    前言:在大量的表单处理中过程中总是会面临这些问题,面对多种cell,行数众多,操作繁琐、显示隐藏等等的问题。 一:...

  • 隐藏软键盘

    隐藏软键盘: Fragment中与显示同理。

  • UICollectionViewCell 位置获取

    // 获取 cell 在屏幕中的位置 , 根据 cell 的 x ,判断cell的位置,是否显示 line

  • 如何隐藏UITableViewCell

    有时候需要隐藏特定的cell,我的做法是在将cell的高度变为很小的数,比如0.01,并设置裁剪效果。在需要显示时...

  • Editor-显示隐藏管理工具

    该工具主要用来快捷的控制场景中多个物体的显示与隐藏。效果如下:首先在Hierarchy视图框中右键创建“显示隐藏管...

  • 04-jQuery动效

    jQuery效果 显示与隐藏动画 显示 show([speed,[easing],[fn]); 隐藏 hide([...

网友评论

      本文标题:iOS-TableView中cell的显示与隐藏

      本文链接:https://www.haomeiwen.com/subject/dbuczttx.html