Search code examples
iosobjective-cuitableviewpull-to-refreshuitableviewsectionheader

UITableview refreshing cells scrolling under section header


I am using UzysCircularProgressPullToRefresh in order to refresh my tableview. My UITableView have 1 static section with a title and I want it always fixed at the top of the table(That's why I don't want to use UITableViewStyleGrouped). When the UITableView is in refreshing state, and I start scrolling it, the cells are being scrolling under the header section which is very bad as a design. Kindly check the image check the Image here

You can test it by yourself by adding the following to the project:

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    return @"Header Section";
}

I tried to find a solution but didn't find any after lot of searching. Can anyone help me solving this? how to fix this design issue in any way?


Solution

  • - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
        CGFloat navBarMaxY = CGRectGetMaxY(self.navigationController.navigationBar.frame);
        if (scrollView.contentInset.top > navBarMaxY) {
            if (scrollView.contentInset.top > -scrollView.contentOffset.y) {
                UIEdgeInsets insets = scrollView.contentInset;
                insets.top = MAX(-scrollView.contentOffset.y, navBarMaxY);
                scrollView.contentInset = insets;
            }
        }
    }