UITableView section header creeps under navigation bar

Nirav Bhatt picture Nirav Bhatt · Dec 3, 2012 · Viewed 16.4k times · Source

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?

Answer

Nirav Bhatt picture Nirav Bhatt · Dec 4, 2012

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.