iOS开发笔记--如何去掉UItableview header(footer)view黏性(sticky)
2016-01-27 10:08
555 查看
今天做项目时候发现要去掉section在tableview中的黏性
下面代码可以却掉,但是消耗比较大,table滚动时候要不停的执行
[objc] view
plain copy
//去掉UItableview headerview黏性(sticky)
- (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);
}
}
下面的方法相对较好
[objc] view
plain copy
_mainTable.contentInset = UIEdgeInsetsMake(sectionHeight, 0, 0, 0);
这样实际上市吧table向上移动了一部分隐藏在navigation下面
下面代码可以却掉,但是消耗比较大,table滚动时候要不停的执行
[objc] view
plain copy
//去掉UItableview headerview黏性(sticky)
- (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);
}
}
下面的方法相对较好
[objc] view
plain copy
_mainTable.contentInset = UIEdgeInsetsMake(sectionHeight, 0, 0, 0);
这样实际上市吧table向上移动了一部分隐藏在navigation下面
相关文章推荐
- [iOS 技术]相对布局 获取 UITableView中内容的高度,设置UITableView中内容的高度与UITableView高度相同
- iOS开发笔记--异步加载UIImageView----AsyImageView
- iOS开发笔记--解决UITableView中Cell重用机制导致内容出错的方法总结
- iOS给UIView添加延展使用与Button、uiview。。。
- 把乐谱播出来,自制Arduino简谱播放库
- 【NGUI】NGUI适配源码
- easyui datagrid 动态添加、移除editor
- Ueditor 编译发布后无法使用上传图片、附件等功能
- 1Z0-050 question 2
- CAShapeLayer + UIBezierPath
- DataTable转(字符串形式的)json;DataTable转easyui grid可以识别的json结构
- fortran inquire语句
- Threejs 官网 - Three.js 的图形用户界面工具(GUI Tools with Three.js)
- STL 整理(map、set、vector、list、stack、queue、deque、priority_queue)
- IOS简单实现瀑布流UICollectionView
- UIScrollView的相关内容
- Leetcode 187. Repeated DNA Sequences
- UISearchController
- postgresql9.3引入uuid
- hue 安装文档