How to resize a tableHeaderView of a UITableView?
cocoa-touch, iphone, uitableview
Solution
FYI: I've gotten this to work by modifying the tableHeaderView and re-setting it. In this case, i'm adjusting the size of the tableHeaderView when the UIWebView subview has finished loading.
[webView sizeToFit];
CGRect newFrame = headerView.frame;
newFrame.size.height = newFrame.size.height + webView.frame.size.height;
headerView.frame = newFrame;
[self.tableView setTableHeaderView:headerView];
Problem
I'm having trouble resizing a tableHeaderView. It simple doesn't work. 1) Create a UITableView and UIView (100 x 320 px); 2) Set the UIView as tableHeaderView of the UITableView; 3) Build and Go. Everything is ok. Now, I want to resizing the tableHeaderView, so I add this code in viewDidLoad: ``` self.tableView.autoresizesSubviews = YES; self.tableView.tableHeaderView = myHeaderView; self.tableView.tableFooterView = myFooterView; CGRect newFrame = self.tableView.tableHeaderView.frame; newFrame.size.height = newFrame.size.height + 100; self.tableView.tableHeaderView.frame = newFrame; ``` The height of the tableHeaderView should appear with 200, but appears with 100. If I write: ``` self.tableView.autoresizesSubviews = YES; CGRect newFrame = myHeaderView.frame; newFrame.size.height = newFrame.size.height + 100; myHeaderView.frame = newFrame; self.tableView.tableHeaderView = myHeaderView; self.tableView.tableFooterView = myFooterView; ``` Then it starts with 200 of height, as I want. But I want to be able to modify it in runtime. I've also tried this, without success: ``` self.tableView.autoresizesSubviews = YES; self.tableView.tableHeaderView = myHeaderView; self.tableView.tableFooterView = myFooterView; CGRect newFrame = self.tableView.tableHeaderView.frame; newFrame.size.height = newFrame.size.height + 100; self.tableView.tableHeaderView.frame = newFrame; [self.tableView.tableHeaderView setNeedsLayout]; [self.tableView.tableHeaderView setNeedsDisplay]; [self.tableView setNeedsLayout]; [self.tableView setNeedsDisplay]; ``` The point here is: How do we resize a tableHeaderView in runtime ??? Have anyone able to do this? Thanks iMe