forkingdog / forkingdog/UITableView-FDTemplateLayoutCell

优化高度计算fd_systemFittingHeightForConfiguratedCell

Open
#400 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Objective-C
Stars
9.9k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

- (CGFloat)fd_systemFittingHeightForConfiguratedCell:(UITableViewCell *)cell {
CGFloat contentViewWidth = CGRectGetWidth(self.frame);

如果self即UITableView使用代码添加约束时,第一次调用fd_systemFittingHeightForConfiguratedCell方法时UITableView宽度为0,在使用- (CGFloat)fd_heightForCellWithIdentifier:(NSString *)identifier cacheByIndexPath:(NSIndexPath *)indexPath configuration:(void (^)(id cell))configuration使用缓存高度时,如果UITableView不刷新,缓存高度不对,应改为

- (CGFloat)fd_systemFittingHeightForConfiguratedCell:(UITableViewCell *)cell {
if (self.superview) {
[self.superview layoutIfNeeded];
}

CGFloat contentViewWidth = CGRectGetWidth(self.frame);
使用layoutIfNeeded获取UITableView正确宽度

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.