Masonry icon indicating copy to clipboard operation
Masonry copied to clipboard

Masonry not working with TableViewCell

Open runryan opened this issue 8 years ago • 2 comments

New Issue Checklist

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

  • [x] I have looked at the Documentation
  • [x] I have filled out this issue template.

Issue Info

Info Value
Platform Xcode; iOS;
Platform Version Xcode 9.0.1; iOS 11.0 & iOS 10.2
Masonry Version 1.0.2
Integration Method cocoapods

Issue Description

Here is my Debug info:

Unable to simultaneously satisfy constraints.
	Probably at least one of the constraints in the following list is one you don't want. 
	Try this: 
		(1) look at each constraint and try to figure out which you don't expect; 
		(2) find the code that added the unwanted constraint or constraints and fix it. 
(
	<MASLayoutConstraint:0x6040000bdee0 UIImageView:iconView.height == 70>,
	<MASLayoutConstraint:0x6040000bdfa0 UIImageView:iconView.top == UITableViewCellContentView:0x7fdc53d7ab70.top + 7>,
	<MASLayoutConstraint:0x6040000be120 UIImageView:iconView.bottom == UITableViewCellContentView:0x7fdc53d7ab70.bottom - 7>,
	<NSLayoutConstraint:0x604000284d80 UITableViewCellContentView:0x7fdc53d7ab70.height == 43.5>,
)

Will attempt to recover by breaking constraint 
<MASLayoutConstraint:0x6040000bdee0 UIImageView:iconView.height == 70>

As you can see i have set iconView top bottom and height constraint relative to contentView of UITableViewCell, and i also did the row height things:

        tableView.estimatedSectionFooterHeight = 0;
        tableView.estimatedSectionHeaderHeight = 0;
        tableView.estimatedRowHeight = 100;
        tableView.rowHeight = UITableViewAutomaticDimension;

the code works just fine until yesterday. Really wired. May it be Masonry's problem or Xcode's?

⚠️ Replace this with the description of your issue. ⚠️

runryan avatar Oct 24 '17 02:10 runryan

Why not using the tableView.rowHeight = 84;? You just have a simple constant cell height requirement.

xingheng avatar Oct 31 '17 04:10 xingheng

Works for me:

UIImageView *iconView = [[UIImageView alloc] init];
iconView.backgroundColor = UIColor.orangeColor;
[self.contentView addSubview:iconView];
[iconView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.mas_equalTo(7);
    make.bottom.mas_equalTo(-7).priorityHigh();  // look this
    make.size.mas_equalTo(70);
}];

cntrump avatar Jun 01 '21 14:06 cntrump