Hi, could you explain the context of this piece of code if you have time?
Is it supposed to be called in a viewDidLayoutSubviews for example?
In my case, I am using a container for my headerView and I add the container to the tableheaderView.
It does not seem it will affect what I am doing here :/
For a little bit of context on my side:
// This is a setup function in my viewDidLoad
UIView *headerContainerView = [UIView new];
self.headerView = [CustomView new];
[headerContainerView addSubview:self.headerView];
[self.headerView updateWithTitle:@"Test"andDescription:@"Test description"];
[self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(headerContainerView.mas_top).offset(16);
make.leading.equalTo(headerContainerView.mas_leading).offset(16);
make.trailing.equalTo(headerContainerView.mas_trailing).offset(-16);
make.bottom.equalTo(headerContainerView.mas_bottom).offset(-16);
}];
headerContainerView.transform = self.tableView.transform; // It is legacy code, so the tableview right now is inverted. it should not impact the way we show the tableview.
self.tableView.tableFooterView = headerContainerView;
// The following code was executed before for `tableHeaderView` in the rest of the app, and it was working like a charm. But since I dig a little bit about `tableHeaderViews` apparently set `translatesAutoresizingMaskIntoConstraints ` to `NO` might cause a problem, without even applying any constraints.// [headerContainerView mas_makeConstraints:^(MASConstraintMaker *make) {// make.centerX.equalTo(self.tableView.mas_centerX);// make.width.equalTo(self.tableView.mas_width);// make.top.equalTo(self.tableView.mas_top);// }];
And then, I have my current ViewController containing this setup that has override viewDidLayoutSubviews:
// It is clearly a workaround for this auto layout issues with tableHeaderView
[superviewDidLayoutSubviews];
if (self.tableView.tableFooterView == nil) {
return;
}
UIView *tableFooterView = self.tableView.tableFooterView;
CGFloat footerHeight = [tableFooterView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
CGRect footerFrame = tableFooterView.frame;
if (footerHeight != footerFrame.size.height) {
footerFrame.size.height = footerHeight;
tableFooterView.frame = footerFrame;
[self.tableView setTableFooterView:tableFooterView];
}
Hi, could you explain the context of this piece of code if you have time?
Is it supposed to be called in a
viewDidLayoutSubviews
for example?In my case, I am using a container for my headerView and I add the container to the
tableheaderView
.It does not seem it will affect what I am doing here :/
For a little bit of context on my side:
And then, I have my current
ViewController
containing this setup that has overrideviewDidLayoutSubviews
:Thank you for your further help and time.