Pergunta

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?

Foi útil?

Solução

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.

Outras dicas

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

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.

Easiest solution:

tableView.tableHeaderView = UIView()
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top