From 9c3559eee2229951bb8702a95ba009e3b0d78d90 Mon Sep 17 00:00:00 2001 From: changle Date: Mon, 29 Aug 2016 18:02:16 +0800 Subject: [PATCH] fix bug on header footer view --- Classes/UITableView+FDTemplateLayoutCell.m | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Classes/UITableView+FDTemplateLayoutCell.m b/Classes/UITableView+FDTemplateLayoutCell.m index 64305c1..04a62bc 100644 --- a/Classes/UITableView+FDTemplateLayoutCell.m +++ b/Classes/UITableView+FDTemplateLayoutCell.m @@ -202,8 +202,21 @@ - (__kindof UITableViewHeaderFooterView *)fd_templateHeaderFooterViewForReuseIde } - (CGFloat)fd_heightForHeaderFooterViewWithIdentifier:(NSString *)identifier configuration:(void (^)(id))configuration { + if (!identifier) { + return 0; + } + + UITableViewHeaderFooterView *templateHeaderFooterView = [self fd_templateHeaderFooterViewForReuseIdentifier:identifier]; + + [templateHeaderFooterView prepareForReuse]; + + if (configuration) { + configuration(templateHeaderFooterView); + } + + NSLayoutConstraint *widthFenceConstraint = [NSLayoutConstraint constraintWithItem:templateHeaderFooterView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:CGRectGetWidth(self.frame)]; [templateHeaderFooterView addConstraint:widthFenceConstraint]; CGFloat fittingHeight = [templateHeaderFooterView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;