当tableview style设置为ground时,每个section的header会跟随tableview一起上下滑动;当style设置为plain时,每个section的header会悬浮在屏幕最上面,直到下一个section的header划过来,把当前的替换掉。现在的问题是,可以在style为plain时,让header也跟随tableview一起上下滚动吗,而不停在屏幕最上的部分。
//去掉UItableview headerview黏性
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView == self.myTableView)
{
CGFloat sectionHeaderHeight = YOUR_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);
}
}
}