A recent problem is the use of a separate xib file AutoLayout to create a UITableView tableheader. This xib is a dynamic-height view.
So there is a problem, the view created with Xib is fixed height, if used directly:
M_contenttableview.tableheaderview= Headerview;
Such a statement to set Headerview, then the Headerview will always be a fixed height, if the content is too large to display incomplete, if the content is too small, then left a blank.
Tried the Headview internally with a variable m_bneedheight to record the height of the headerview inside the actual need, and then at each time this
M_bneedheight, modify the Headerview Frame outside, the code is as follows:
-(void) onneedsheightchanged: (cgfloat) nneedsheight
{
Circledetailsheaderview * Headerview = [self getheaderview];
if (Headerview)
{
CGRect frame = headerview.frame;
Frame.size.height = Nneedsheight;
Headerview.frame = frame;
}
}
This is good, haha, run, found the egg, which is not a bird.
What's the problem?
Finding the following is the ultimate problem-solving code:
-(void) onneedsheightchanged: (cgfloat) nneedsheight
{
Circledetailsheaderview * Headerview = [self getheaderview];
if (Headerview)
{
CGRect frame = headerview.frame;
Frame.size.height = Nneedsheight;
Headerview.frame = frame;
M_contenttableview.tableheaderview = Headerview;
}
That is, not only to reset the frame, but also to re-assign the value to TableView, so that TableView will go to the layout of the outside to assign the value of the past Headerview position and size.