7

Due to navigation bar style being translucent, I get my first section header (section # 0) hidden under my navigation bar.

I know this has been asked before, and a workaround to it is to do:

 self.navController.navigationBar.translucent = YES;

This places the problematic view correct - section header appears beneath the navigation bar instead of hiding behind it, which is what I want.

However, this invalidates my other view designs and leaves extra spaces in all of them, right under my nav bar.

How do I get the section header at correct place?

Nirav Bhatt
  • 6,940
  • 5
  • 45
  • 89

4 Answers4

14

Resolved:

  • Open storyboard file
  • select UITableView
  • Under attribute inspector -> Scroll view size -> Content insets, set Top = 44 (or whichever is your nav bar height).

See image below - it is under size section:

enter image description here

And here is how to fix it programmatically.

Community
  • 1
  • 1
Nirav Bhatt
  • 6,940
  • 5
  • 45
  • 89
  • Where is attribute inspector? – Gank Jun 10 '14 at 17:54
  • Content insets don't exist in the inspector, only scroll indicators insets. – Steve Jul 30 '14 at 12:00
  • @SteveTaylor - check if you accidentally hid it using Hide button. – Nirav Bhatt Jul 30 '14 at 12:50
  • 1
    I checked again. It's not hidden. It's simply not there. Nevertheless, I resolved this problem not with magic numbers but instead by embedding my `UITableViewController` in a `UINavigationViewController`. – Steve Jul 30 '14 at 13:21
8

To solve this while using SVPullToRefresh. I created the method below and inplace of [self.tableView.pullToRefreshView stopAnimating];

-(void)stopPullToRefreshAnimation
{
    [self.tableView.pullToRefreshView stopAnimating]; // call to stop animation

    UIEdgeInsets inset = UIEdgeInsetsMake(44, 0, 0, 0);
    self.tableView.contentInset = inset;
    self.tableView.scrollIndicatorInsets = inset;
} //stopPullToRefreshAnimation
ShawnG
  • 123
  • 1
  • 6
1

For others having this issue while using (SVPullToRefresh).

It can be solved by changing the view.originalTopInset in UIScrollView+SVPullToRefresh.m to whatever point you want your header to start at.

Abuirshaid
  • 11
  • 1
  • Tariq can you please share detail on this? After initial scrolling operation I can never get my first tableview element to be seen it creeps up under the navcontroller/bar. I see in the SVPullToRefresh code the originalTopInset var but it is used in many places - where should I change it and how? – Mike Kogan Mar 11 '14 at 22:13
1

Easiest solution:

tableView.tableHeaderView = UIView()
Joshua Hart
  • 772
  • 1
  • 21
  • 31