Skip to content

优化高度计算fd_systemFittingHeightForConfiguratedCell #400

@yuekewei

Description

@yuekewei
  • (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正确宽度

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions