您的位置:首页 > 产品设计 > UI/UE

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下面
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: