views:

176

answers:

1

I have a UITableView inside a UINavigationController. The navigation controller uses a translucent navigation bar--as a result, my table view is displayed behind the navigation bar and it's height includes the height of the navigation bar. However, I want the table view to appear below the navigation bar (as it would if it were not translucent).

I'm working in MonoTouch, but I think the principles are language independent. Here's the code I'm using to resize the UITableView frame:

RectangleF rect = tableView.Frame;
tableView.Frame = new RectangleF (rect.Left, rect.Top + 44, rect.Width, rect.Height - 44);
tableView.ContentInset = new UIEdgeInsets (0, 0, 0, 0);

This works fine if I place it in the viewDidAppear method, but will not work in the viewWillAppear method. In the viewDidAppear method, however I can see the resize occurring briefly in the form of a flicker. I want to do the resize before the frame appears. But if I put this code in viewWillAppear or viewDidLoad, it has no effect.

Thanks in advance for any help!

A: 

You can add a custom tableHeaderView to the table that's the same height as the navigation bar (44 pixels). That will push down the rest of the table.

sbwoodside
I tried this, but had several problems. I want things that scroll up from my table to be blocked by the navigation bar (it's translucent to allow a background from a parent view to show through). Specifically, I have a search bar at the top of my table that looks bad when it's behind the navigation bar. Since I default to it being scrolled behind the bar (like in contacts), my view looks poor in it's default condition. I need the searchbar to be entirely gone when it scrolls off. Also, I want the section headers to stop at the navigation bar, not appear underneath it as I scroll.
scotru