关于cell自适应高度的注意点

1.设置estimatedRowHeight的值,必须给一个值!
2.约束一定要从顶部贯穿到底部
比如

[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.mas_equalTo(12);
        make.right.mas_equalTo(-12);
        make.height.mas_greaterThanOrEqualTo(20);//内容变化的label要设置高度大于
        
    }];
    
    [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom).offset(10);
        make.left.mas_equalTo(12);
        make.right.mas_equalTo(-12);
        make.height.mas_equalTo(80);
    }];
    
    [self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.stackView.mas_bottom).offset(5);
        make.height.mas_equalTo(25);
        make.right.equalTo(self.stackView);
        make.width.mas_equalTo(20);
        make.bottom.mas_equalTo(-10);
    }];
    
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.closeButton);
        make.left.equalTo(self.titleLabel);
        make.right.equalTo(self.closeButton.mas_left).offset(-10);
        make.height.mas_equalTo(20);
        
    }];

3.约束不能在layoutSubviews里面设置,要在添加到父视图的时候设置(这点很重要!!!!)习惯在layoutSubviews里面设置约束的同学需要注意了

你可能感兴趣的:(cell自适应高度,masonry约束,高度刷新延迟,IOS开发,OC)