在UITableViewStylePlain情况下sectionHeader可以与tableview一起滑动的解决方法

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGFloat sectionHeaderHeight = 20;
    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);
    }
}

在 -(void)scrollViewDidScroll:(UIScrollView *)scrollView方法中添加上诉代码即可

原文地址:https://www.cnblogs.com/cityingma/p/5183154.html