tableview的第一个section的header悬浮问题

这种问题的出现的原因是table的style设置成了plain样式。

有三种解决方案:

1.去粘性(消耗大)

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {

    if (scrollView == self.tableView)

    {

        CGFloat sectionHeaderHeight = EMSET_CELL_HEIGHT;

        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);

        }

    }

}

2、将tableview设置成group样式

3、将第一个section header变成整个table的name.

posted @ 2016-02-16 10:50  wangbaixue  阅读(817)  评论(0编辑  收藏  举报