iOS开发笔记--如何去掉UItableview header(footer)view黏性(sticky)
2014-09-12 09:54
519 查看
今天做项目时候发现要去掉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下面
相关文章推荐
- iOS开发笔记--如何去掉UItableview header(footer)view黏性(sticky)
- iOS开发笔记--如何去掉UItableview header(footer)view黏性(sticky)
- iOS开发笔记--如何去掉UItableview header(footer)view黏性(sticky)
- iOS开发-去掉UITableView HeaderView或FooterView随tableView 移动的黏性(sticky
- iOS 去掉UItableview header(footer)view黏性(sticky)?
- 如何去掉UItableview header(footer)view黏性(sticky)?
- 去掉UItableview header(footer)view 黏性(sticky)
- 去掉UItableview header(footer)view黏性(sticky)
- 去掉UItableview header(footer)view黏性(sticky)
- iOS开发笔记--去掉tableview中section的headerview粘性
- iOS开发笔记--去掉tableview中section的headerview粘性
- iOS开发笔记--去掉tableview中section的headerview粘性
- iOS开发笔记--去掉tableview中section的headerview粘性
- 去掉UItableview header(footer)view黏性
- iOS开发-- 如何让 UITableView 的 headerView跟随 cell一起滚动
- iOS设置tableViewCell之间的间距(去掉UItableview headerview黏性)
- 去掉UITableView的header和footer的黏性效果
- iOS开发之UITableView自定义Header视图和自定义Footer视图
- iOS开发之去掉UItableview header的粘性
- iOS开发笔记--去掉tableview中section的headerview粘性