I want to be able to show part of the header view of a table when the user pulls down the tableview to make it visible. Similarly, I want to hide it when the user pushes the header out of view.
To do this I have set a content inset to hide the top part of the table. I have also set a content offset to hide the part I want to show
+------------------------------+
| Top part of header (hidden) |
+------------------------------+
| |
| Bottom part (I want to show) |
| |
+------------------------------+
| |
| |
| Table view |
| |
| |
+------------------------------+
The problem is, when I scroll the view, the content offset seems to reset and show the part I wanted to show, even when I push the table up.
This problem is stopping me from using scrollViewWillEndDragging:withVelocity:targetContentOffset:targetContentOffset
to animate the content offset relative to the direction I am scrolling.
Here is my code (in viewDidAppear:
)
CGRect hiddenPartOfHeaderFrame = self.hiddenPartOfHeaderFrame.frame;
UIEdgeInsets tableContentInset = UIEdgeInsetsMake(- CGRectGetHeight(hiddenPartOfHeaderFrame), 0.0f, 0.0f, 0.0f);
[self.tableView setContentInset:tableContentInset];
CGPoint tableContentOffset = CGPointMake(0.0f, (CGRectGetHeight(self.tableView.tableHeaderView.frame)));
[self.tableView setContentOffset:tableContentOffset];
Is it a property of the content offset to change on scroll, or is there something else going on here I'm not taking in to account?
Thanks as always