Resize a UITableView to accomodate a translucent header before it becomes visible

Posted by scotru on Stack Overflow See other posts from Stack Overflow or by scotru
Published on 2010-05-29T07:12:08Z Indexed on 2010/05/29 7:22 UTC
Read the original article Hit count: 394

Filed under:
|
|

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!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk