UITableView不让section悬浮

来源:互联网 发布:淘宝账号怎样贷款 编辑:程序博客网 时间:2024/04/28 21:23

方法一、

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


   CGFloat sectionHeaderHeight = 100;

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

    }

}


方法二、

设置tableView的类型为Grouped即可

0 0
原创粉丝点击