开发者

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

开发者 https://www.devze.com 2023-01-01 06:03 出处:网络
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 inc

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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消