去掉UItableview header(footer)view黏性
2015-12-28 18:22
405 查看
今天做项目时候发现要去掉section在tableview中的黏性
下面代码可以却掉,但是消耗比较大,table滚动时候要不停的执行
//去掉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);
}
}
下面的方法相对较好
_mainTable.contentInset = UIEdgeInsetsMake(<span style="font-family:Microsoft YaHei;">sectionHeight</span>, 0, 0, 0);
这样实际上市吧table向上移动了一部分隐藏在navigation下面
下面代码可以却掉,但是消耗比较大,table滚动时候要不停的执行
//去掉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);
}
}
下面的方法相对较好
_mainTable.contentInset = UIEdgeInsetsMake(<span style="font-family:Microsoft YaHei;">sectionHeight</span>, 0, 0, 0);
这样实际上市吧table向上移动了一部分隐藏在navigation下面
相关文章推荐
- UIview的创建
- NGUI的原理机制:深入剖析UIPanel,UIWidget,UIDrawCall底层原理
- 限制UITextField输入内容的长度
- UI - UITableView 移动
- UIWindows介绍
- SSLHandshakeException: *.ValidatorException: PKIX path building failed: *.SunCertPathBuilderExceptio
- AlertDialog.Builder弹出各类窗口实现
- 使用BlockingQueue创建生产者消费者模式
- UI - UITableView 编辑 、TableViewController
- NSOperationQueue 队列
- Android酷炫实用的开源框架(UI框架)
- [leetcode] 225. Implement Stack using Queues 解题报告
- ios UISearchDisplayController 实现 UITableView 搜索功能
- 创建队列 NSOperationQueue dispatch队列组
- iOS页面之间跳转隐藏UITabbar
- request.getRequestDispatcher()的两个方法forward()/include()!!!
- Burp Suite使用介绍——准备工作
- 解决小米手机出现INSTALL_FAILED_UID_CHANGE错误,安装应用失败的问题
- response.setCharacter和request.setCharacterEncoding详解
- Get Jenkins job build queue length