Section Headers in UITableView when inset of tableview is changed

When doing this, I usually use the table-wide header in UITableView instead:

@property(nonatomic, retain) UIView *tableHeaderView

...instead of contentInsets. There were a lot of bugs with contentInsets all the way back to iOS 2.x days, and I'm not sure they've all been fixed. Is there a reason you can't use a table header?


Try this way to add push view controller.

  • Create a table view controller and add it as the sub view of existing view controller.
  • Then assign your table view and refresh controllers to tableview controller's properties.

    UITableViewController *newTableViewController = [[UITableViewController alloc] init];
    newTableViewControler.tableView = <yourTableView>;
    
    <yourRefreshController> = [[UIRefreshControl alloc] init];
    [<yourRefreshController> addTarget:self
                                action:@selector(refreshTableView:)
                      forControlEvents:UIControlEventValueChanged];
    
    newTableViewController.refreshControl = _chatListRefreshControl;
    [self addChildViewController:newTableViewController];
    

I had the same problem when using contentInset and fixed it by adding code to scrollViewDidScroll: to update the contentInset dynamically while in the "loading" state.

if( refreshState == kLoading ) {
    if( scrollView.contentOffset.y >= 0 )
        scrollView.contentInset = UIEdgeInsetsZero;
    else
        scrollView.contentInset = UIEdgeInsetsMake( MIN( -scrollView.contentOffset.y, kPullHeight ), 0, 0, 0 );
}