There is a need to show some different data at the top of the list, and this kind of data needs to be shown by a different View, which is UITableView's tableheaderview.
If the content in the Tableheaderview is fixed, the height should not change with the content, so it is OK.
If the height needs to be changed dynamically, some people (like me) may encounter a problem like this:
I have set the value of each sub-view in the view, the height has been calculated, the frame has been reset, but the height of the Tableheaderview is still the height of the previous, no change. Content becomes more, there will be a part of the invisible, the content is less, there is a part of the blank, put there is really not good.
What to do??
View as TableView Tableheaderview, simply change the frame of the view is useless, TableView will not be generous to the moment to adapt to its height (after Apple will not change it does not know), so, how to tell Tablevi EW, has its tableheaderview changed? Very simple, just a word (the last sentence):
The bounds of the headbgview in advance of obtaining restraint
[Self.headbgview Setneedslayout];
[Self.headbgview layoutifneeded];
CGRect Newframe == newFrame.size.height += newframe;[ Self.tableview Settableheaderview:headerview];
After that, the effect comes out. But this excessive seems a bit stiff, can add a little animation, let it become more pleasing to the eye? Try the following code:
[Self.tableview beginupdates]; [Self.tableview Settableheaderview:headerview]; [Self.tableview endupdates];
UITableView: Change the height of Tableheaderview