Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

优化高度计算fd_systemFittingHeightForConfiguratedCell #400

Open
yuekewei opened this issue Apr 4, 2019 · 1 comment
Open

优化高度计算fd_systemFittingHeightForConfiguratedCell #400

yuekewei opened this issue Apr 4, 2019 · 1 comment

Comments

@yuekewei
Copy link

yuekewei commented Apr 4, 2019

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

@JiaoYingBo
Copy link

666,可以的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants