Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Classes/UITableView+FDTemplateLayoutCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
///
@property (nonatomic, assign) BOOL fd_debugLogEnabled;

/**
* Use this if you don't want to remove cache when reload tableView
*/
- (void)fd_reloadData:(BOOL)shouldRemoveCache;

@end

@interface UITableViewCell (FDTemplateLayoutCell)
Expand Down
25 changes: 16 additions & 9 deletions Classes/UITableView+FDTemplateLayoutCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,15 @@ - (NSArray *)fd_allIndexPathsToBePrecached

@implementation UITableView (FDTemplateLayoutCellAutomaticallyCacheInvalidation)

- (void)fd_reloadData:(BOOL)shouldRemoveCache
{
if (self.fd_autoCacheInvalidationEnabled && shouldRemoveCache) {
[self.fd_cellHeightCache.sections removeAllObjects];
}
[self fd_reloadData]; // Primary call
[self fd_precacheIfNeeded];
}

+ (void)load
{
// All methods that trigger height cache's invalidation
Expand Down Expand Up @@ -305,11 +314,7 @@ + (void)load

- (void)fd_reloadData
{
if (self.fd_autoCacheInvalidationEnabled) {
[self.fd_cellHeightCache.sections removeAllObjects];
}
[self fd_reloadData]; // Primary call
[self fd_precacheIfNeeded];
[self fd_reloadData:YES];
}

- (void)fd_insertSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation
Expand Down Expand Up @@ -483,10 +488,12 @@ - (CGFloat)fd_heightForCellWithIdentifier:(NSString *)identifier configuration:(
attribute:NSLayoutAttributeNotAnAttribute
multiplier:1.0
constant:contentViewWidth];
[cell.contentView addConstraint:tempWidthConstraint];
// Auto layout engine does its math
fittingSize = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
[cell.contentView removeConstraint:tempWidthConstraint];
@synchronized(cell.contentView) {
[cell.contentView addConstraint:tempWidthConstraint];
// Auto layout engine does its math
fittingSize = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
[cell.contentView removeConstraint:tempWidthConstraint];
}

} else {

Expand Down