zoukankan      html  css  js  c++  java
  • IOS-tableView中的cellHeadView随着table滚动

    IOS-tableView中的cellHeadView随着table滚动

    设置table的style

    首先要将table设置为UITableViewStyleGrouped类型。这样就会得到tableView中的headView随着table的滚动而滚动的现象了。

    设置tableSection的高度

    然后我们可以通过方法
    tableView:heightForFooterInSection:
    tableView:heightForHeaderInSection:
    来控制tableSection中的header和Footer的高度。

    这里需要注意一下,这里的高度如果设置为了0,那么函数是识别不出来的,一定要设置为一个小数,建议要设置为零的话,可以设置CGFLOAT_MIN。

    下面是一个例子:

    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
        return 10;//设置tableHeader的高度,10,可以识别
    }
    
    
    - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
        if (section == 0) {
            return CGFLOAT_MIN;//最小数,相当于0
        }
        else if(section == 1){
            return CGFLOAT_MIN;//最小数,相当于0
        }
        return 0;//机器不可识别,然后自动返回默认高度
    }

    设置tableSection中的header和footer的view

    - (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
        view.backgroundColor = [UIColor redColor];
    
        return view;
    }
  • 相关阅读:
    java数据结构-循环链表实现
    java数据结构-普通链表实现测试
    java数据结构-普通链表实现
    java数据结构-排序算法-插入算法
    java数据结构-排序算法-快排算法
    java数据结构-递归算法-简单递归算法
    python------------------异常处理
    自定义Web框架
    Django框架第一篇
    Django框架之第二篇
  • 原文地址:https://www.cnblogs.com/AbeDay/p/5026921.html
Copyright © 2011-2022 走看看