SnapKit / Masonry

Harness the power of AutoLayout NSLayoutConstraints with a simplified, chainable and expressive syntax. Supports iOS and OSX Auto Layout
MIT License
18.05k stars 3.14k forks source link

When I use masonry to auto layout UI,I often encounter such error messages, the UI can sometimes display correctly, sometimes it does not display properly. #557

Closed gdxud2016 closed 5 years ago

gdxud2016 commented 5 years ago

New Issue Checklist

🚫 If this template is not filled out your issue will be closed with no comment. 🚫

Issue Info

Info Value
Platform e.g. ios/osx/tvos
Platform Version e.g. 8.0
Masonry Version e.g. 1.0
Integration Method e.g. carthage/cocoapods/manually

Issue Description

error log: "<MASLayoutConstraint:0x6000017d91a0 UIImageView:0x7f9ee95034e0.top == UITableViewCellContentView:0x7f9ee952e340.top + 16>", "<MASLayoutConstraint:0x6000017da700 UIImageView:0x7f9ee95034e0.height == 76>", "<MASLayoutConstraint:0x6000017d8fc0 UILabel:0x7f9ee95015d0.bottom == UIImageView:0x7f9ee95034e0.bottom>", "<MASLayoutConstraint:0x6000017d9e60 UILabel:0x7f9ee9527c90.top == UILabel:0x7f9ee95015d0.bottom + 16>", "<MASLayoutConstraint:0x6000017db4e0 UILabel:0x7f9ee9527c90.bottom == UITableViewCellContentView:0x7f9ee952e340.bottom - 16>", "<NSLayoutConstraint:0x6000010e0780 UITableViewCellContentView:0x7f9ee952e340.height == 107.5>" )

Will attempt to recover by breaking constraint <MASLayoutConstraint:0x6000017da700 UIImageView:0x7f9ee95034e0.height == 76>

I often set the imageview priorityMedium,it will not show this log, but this time does not work, and the UI shows an error.Can you help me solve this problem? this my iOS code:

[_userIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.left.equalTo(self.contentView).offset(leftmargin);
    make.width.height.offset(76);
}];

[_userNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(_userIconImageView.mas_top);
    make.left.equalTo(_userIconImageView.mas_right).offset(leftmargin);
    make.right.equalTo(self.contentView.mas_right).offset(-10);
}];

[_userCompanyNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.bottom.equalTo(_userIconImageView.mas_bottom);
    make.left.right.equalTo(_userNameLabel);
}];

[indicatorImageView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.centerY.equalTo(_userIconImageView);
    make.right.equalTo(self.contentView.mas_right).offset(-10);
    make.width.offset(9);
    make.height.offset(15);
}];

[_companyScoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(_userCompanyNameLabel.mas_bottom).offset(leftmargin);
    make.left.equalTo(self.contentView.mas_left).offset(leftmargin);
    make.bottom.equalTo(self.contentView.mas_bottom).offset(-rightmargin);
}];

[_personalScoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.equalTo(_companyScoreLabel.mas_top);
    make.left.equalTo(_companyScoreLabel.mas_right);
    make.right.equalTo(self.contentView.mas_right).offset(-rightmargin);
    make.width.equalTo(_companyScoreLabel);
}];
gdxud2016 commented 5 years ago

replace a new MASLayoutConstraint