自定义分区标题不随着table滑动
2015-09-08 19:24
260 查看
再OC中,table分区标题默认是不随着tableview滑动的,当此分区下面的数据全部滑出界面的时候,分区视图才跟着滑动,在QQ等app上也都采用的这种方式
现在问题来了,我要在滑动table的时候,tableHeadView就跟着一起滑动、
实际上 只需要加入一个函数、
//headView跟随tableView一起滑动
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView == self.tableView)
{
CGFloat sectionHeaderHeight = 22;
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);
}
}
}
现在问题来了,我要在滑动table的时候,tableHeadView就跟着一起滑动、
实际上 只需要加入一个函数、
//headView跟随tableView一起滑动
-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView == self.tableView)
{
CGFloat sectionHeaderHeight = 22;
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);
}
}
}
相关文章推荐
- hdu 1102 Constructing Roads
- 2015多校联合第八场hdu5384Danganronpa AC自动机
- C++中extern “C”含义深层探索
- Unity3d C# Socket 下载文件 (同步到)
- 熟悉linux-安装tomcat
- Mac快速配置adb大法
- 46 Permutations
- [c#]记一次实验室局域网的ARP欺骗
- Web 服务编程,REST 与 SOAP
- 1.1 JavaScript高级程序设计(第3版) 笔记---对象
- 利用python发布新浪微博
- [POJ 1988]Cube Stacking[带权并查集]
- swift的基本使用(3)嵌套函数和闭包
- Visual Studio 2015编译安装OpenCV 3.0和opencv_contrib
- IOS_UITabBarController
- JDK和eclipse下载地址
- 有趣Web之Json(四)---json与(Object/List/Map)相互转化
- 如何快速建立一个优秀的账号体系
- LeetCode || Binary Tree Paths
- 利用javadoc生成API文档