去掉UITableViewController中header的黏性

转自“http://www.cocoachina.com/bbs/read.php?tid=124803”

 

问题现象

多个section的列表上下滚动时,header不会动,并且会覆盖掉cell,想header跟cell一样上下滚动

问题解决

//去掉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);
    }

posted on 2015-03-06 10:52  trako  阅读(190)  评论(0编辑  收藏  举报

导航