I use the method as follows
I have just tried below lines of code, dynamically set the UITableViewHeaderFooterView height size.
self.tableView.estimatedSectionHeaderHeight = 100 self.tableView.sectionHeaderHeight = UITableViewAutomaticDimension
I have the following problems
In iOS9, iOS10 can run normally, and can display properly. But can not be displayed correctly in iOS8, and the following error is displayed:
My analysis is as follows:
From the error prompt, I can see that the problem is NSLayoutConstraint: 0x7f8498d7b890 _UITableViewHeaderFooterContentView: 0x7f8498cb9200.height == 0
But I have never made any Constraints to UITableViewHeaderFooterContentView
How should I fit iOS8?
You need to use the UIView systemLayoutSizeFittingSize:
-(void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];
[ViewHeader setNeedsLayout];
[ViewHeader layoutIfNeeded];
CGFloat height = [ViewHeader systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
CGRect headerFrame = ViewHeader.frame;
headerFrame.size.height = height;
ViewHeader.frame = headerFrame;
[tbl setTableHeaderView:ViewHeader];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.