pictured above we have an iphone, a custom menu controller, and tableView slightly scrolled down
There is also a header on the table view, which is a grey horizontal bar, with a slightly more grey horizontal bar.
I intended for the header to stick to the very top of the view, but instead there is a gap which the scrollable section of the table view can fill when the user scrolls down, but the header remains in an unsightly position below the top of the scrollable area.
How do I fix this?
I tried setting this to a tiny value
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return .001;
}
but this removes the grey background in the header.
Any other suggestions? I also looked at other answers to similar questions but they were not quite addressing my problem (or didn't work).
Also, my tableView and header is made programmatically, no storyboards or xibs or interface builder involved.
edit: guys I took a completely different approach to what I was actually trying to develop, so this problem isn't applicable to me any longer. but self.automaticallyAdjustsScrollViewInsets = NO;
was not the solution to that problem as I was already using it
UITableViewController's views are automatically inset in iOS7 and higher so that they don't start below the navigation bar/status bar. You can controler this behavior by the setAutomaticallyAdjustsScrollViewInsets: method of UIViewController.
I had something similar happen to me in a Swift project but the Property changed is the same. I found that adding this line
self.automaticallyAdjustsScrollViewInsets = NO;
solved my issue and the gap disappeared.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With