tableView组头 组尾滑动

今天布局tableview 要组头组尾滑动 从网上找的代码 很实用 留下来 每天进步一下

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {

if (scrollView == self.detailsTableView)

{

UITableView *tableview = (UITableView *)scrollView;

CGFloat sectionHeaderHeight = 50;

CGFloat sectionFooterHeight = 60;

CGFloat offsetY = tableview.contentOffset.y;

if (offsetY >= 0 && offsetY <= sectionHeaderHeight)

{

tableview.contentInset = UIEdgeInsetsMake(-offsetY, 0, -sectionFooterHeight, 0);

}else if (offsetY >= sectionHeaderHeight && offsetY <= tableview.contentSize.height - tableview.frame.size.height - sectionFooterHeight)

{

tableview.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, -sectionFooterHeight, 0);

}else if (offsetY >= tableview.contentSize.height - tableview.frame.size.height - sectionFooterHeight && offsetY <= tableview.contentSize.height - tableview.frame.size.height)         {

tableview.contentInset = UIEdgeInsetsMake(-offsetY, 0, -(tableview.contentSize.height - tableview.frame.size.height - sectionFooterHeight), 0);

}

}

}

时间: 2024-08-05 10:07:26

tableView组头 组尾滑动的相关文章

UICollectionView 自定义组头组尾的XIB方法

UICollectionView的加载方式和Tableview很像,基本上加载的方法都差不多,尤其是它的数据源的方法和代理方法基本上类似,只不过是名字上有点细微的差别而已.这里面不赘述. 1. UICollectionView为什么要自定义组头和组尾呢?原因是因为如果不自定义,系统会复用Cell,导致加载的控件出现重复的现象. 如下图: 绿色的view为组头,通过视图发现,组头上面的控件出现了叠加的现象. 如何解决上面复用的问题,使用initWithFrame的初始化视图的方法,当cell上的v

iOS监听tableView组头切换事件

- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section 组头将要出现的时候系统会调用: - (void)tableView:(UITableView *)tableView didEndDisplayingHeaderView:(UIView *)view forSection:(NSInteger)section 组头出现的时候系统

给UITextField设置头或尾空白

有时候,我们需要在UITextField的头尾加入一些空白,如下图所示: 其中,黄色和红色部分代表空白. 实现起来,比较简单,只需要设置UITextField的leftView.leftViewMode和rightView.rightViewMode即可,代码如下: 假设现有UItextField * txtField: UIView * rView =[[UIView alloc] initWithFrame:CGRectMake(txtField.frame.size.width - 10,

bootstrap-带有头和尾的面板

1.运行效果如图所示 2.实现代码如下 <!DOCTYPE html> <html> <head>     <meta charset="utf-8">     <meta http-equiv="X-UA-Compatible" content="IE=edge">     <title>面板--带有头和尾的面板</title>     <!-- 最新版本

关于页头页尾的异步加载

在网站中许多页面的页头页尾,都是一样的.采用异步加载,减少代码复用率: 采用PHP+html+jQuery 方法: 1.在名为header.php的页面中:写入页头部分的html <?php header('Content-Type:text/html;charset=UTF-8;'); ?> <div id="top"> <p>页头部分html代码</p> </div> 2.在页面中index.html中:指定要引入页头的位

使用 collectionView 实现表头,区头,区尾

UICollectionView 的使用是跟表的使用是一样,瀑布流的布局会比表的效果更好,这里说一下 collectionView 设置表头, 区头,区尾 设置表头可以约束 collectionView 居上的距离 其中区头,区尾 是继承 UICollectionReusableView 1 // 2 // HomePageViewController.m 3 // MainStoryboard 4 // 5 // Created by mac on 16/4/21. 6 // Copyrigh

UI tableView 的头视图 &amp; &quot;小广告&quot;

self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 64) style:UITableViewStylePlain]; [self.view addSubview:self.tableView]; [_tableView release]; self.tableView.dataSource =

【京东账户】——Mysql/PHP/Ajax爬坑之页头页尾加载

一.引言 实现京东的账户项目,有一个小功能,页头页尾加载.要用到的是Apach环境,Mysql.PHP以及Ajax. 二.实现 原理: 用php文件分别写一个的页头和一个页尾,放在前后两个div里. 通过jquery发送一个请求 请求这个php. 再把里面的一些小按钮,小图标放在这个div里即可. <div id="header"></div> -- <div id="footer"></div> 小知识1:jquer

判断用户的用户名和其基本组的组名是否一致

#!/bin/bash #传递一个用户名参数给脚本,判断此用户的用户名跟其基本组的组名是否一致,并将结果显示出来 #判断是否传递一个参数 if [ ! $# -eq 1 ]; then echo "Usage:./group.sh ARG" exit 1 fi #判断是否存在该用户 id $1 &> /dev/null if [ ! $? -eq 0 ]; then echo "$1 not exits." exit 1 fi #取给定用户所属基本组i