当 UITableView 的 style 属性设置为 Plain 时,这个tableview的section header在滚动时会默认悬停在界面顶端。取消这一特性的方法有两种:

  1. 将 style 设置为 Grouped 。这时所有的section header都会随着scrollview滚动了。不过 grouped 和 plain 的样式有轻微区别,切换样式后也许需要重新调整UI
  2. 重载scrollview的delegate方法
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat sectionHeaderHeight = 40;
if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
} else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
}
}

让UITableView的section header view不悬停的方法的更多相关文章

  1. UITableView section header 不固定

    iOS系统自带的UITableView,当数据分为多个section的时候,在UITableView滑动的过程中,默认section header是固定在顶部的,滑动到下一个section的时候,下一 ...

  2. tableview: 实现tableview 的 section header 跟随tableview滑动

    方法一:(只有一个headerView)一段 如果你的tableview恰好只有一个headerView,实现这种效果就好办了.把要设置的headerView设置成tableView的header而不 ...

  3. UITableView去掉section的header的粘性

    思路:若header的高度为25,在滑动的时候将scrollView的内容偏移量上衣25,其实他还是粘在上面只不过我们看不到他了. ///---用于判断往上滑还是往下滑 var deltaY:CGFl ...

  4. iOS- 如何改变section header

    希望这个从UITableViewDelegate协议里得到的方法可以对你有所帮助: - (UIView *) tableView:(UITableView *)tableView viewForHea ...

  5. UItableview里面的header、footer

    #import "ViewController.h" #import "MJRefresh.h" @interface ViewController () { ...

  6. 下拉刷新和UITableView的section headerView冲突的原因分析与解决方案

    UITableView:下拉刷新和上拉加载更多 [转载请注明出处] 本文将说明具有多个section的UITableView在使用下拉刷新机制时会遇到的问题及其解决方案. 工程地址在帖子最下方,只需要 ...

  7. 设置TableView section header的颜色

      - (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInte ...

  8. 快速设置UITableView不同section对应于不同种类的cell

    快速设置UITableView不同section对应于不同种类的cell 本文主要是为了写明如何在UITableView中,一个section对应于一种类型的cell,写起来不凌乱. 在不封装任何类的 ...

  9. java.lang.IllegalStateException: Cannot add header view to list -- setAdapter has already been called.

    分析:android 4.2.X及以下的版本,addHeaderView必须在setAdapter之前,否则会抛出IllegalStateException. android 4.2.X(API 17 ...

随机推荐

  1. powerdesigner(数据设计工具)

    https://jingyan.baidu.com/album/4f7d57120468c91a2019279f.html?picindex=1  (摘抄 原网地址)

  2. chmod语法

    chmod命令详细用法   指令名称 : chmod 使用权限 : 所有使用者 使用方式 : chmod [-cfvR] [--help] [--version] mode file... 说明 :  ...

  3. nginx 504 Gateway Time-out

    #设定http服务器 http { include mime.types; #文件扩展名与文件类型映射表 default_type application/octet-stream; #默认文件类型 ...

  4. Linux 创建虚拟机,配置网卡,桥接,连接XShell

    一.新建虚拟机 1.“root”    输入密码: 2.看虚拟机的IP地址 “ifconfig” 二.配置网卡 1.更改设置(打开vim编辑) “vim /etc/sysconfig/network- ...

  5. Add和AddRange的使用

    Add 是每次将单个元素添加到集合里面 AddRange可以一次性添加多个元素到集合里面 AddRange例子:         public static int ExecuteCommand(st ...

  6. lettuce行为驱动总结

    1.  pip install lettuce 在Python2.7下安装的 2.  py -3 –m pip install lettuce 在Python3下安装的 3.  执行:进到featur ...

  7. ubuntu pip install MySQL-python mysql_config not found

    在安装 mysql-python时,会出现: sh: mysql_config: not found Traceback (most recent call last):   File "s ...

  8. kolla单节点部署openstack

    virtualbox环境: 双网卡:enp0s3(桥接)   192.168.102.194 enp0s8(桥接)   无ip 块存储  50G 关闭防火墙,selinux. 配置yum源:wget  ...

  9. Discuz! X3 全新安装图文教程

    Discuz! 是腾讯旗下 Comsenz 公司推出的以社区为基础的专业建站平台,帮助网站实现一站式服务.让论坛(BBS).个人空间(SNS).门户(Portal).群组(Group).应用开放平台( ...

  10. jsp后台取出request请求头

    请求发到a2这个servlet 在这个servlet中请求转发到index.jsp 在jsp中如下的java代码 Enumeration headernames=request.getHeaderNa ...