Two non-conflicting constraints throwing NSLayoutConstraint error

I have two constraints on the UILabel linking the lead and tail with the caption.

The problem is that when I open a view in the application, I get this error:

2015-04-11 22:00:24.319 TradingPost[7610:60b] 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. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
"<NSLayoutConstraint:0x17e9da10 H:[UILabel:0x17ef3ca0]-(12)-|   (Names: '|':UITableViewCellContentView:0x17eaceb0 )>",
"<NSLayoutConstraint:0x17e9da40 H:|-(88)-[UILabel:0x17ef3ca0]   (Names: '|':UITableViewCellContentView:0x17eaceb0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x17eb1b00 h=--& v=--& H:[UITableViewCellContentView:0x17eaceb0(0)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x17e9da10 H:[UILabel:0x17ef3ca0]-(12)-|   (Names: '|':UITableViewCellContentView:0x17eaceb0 )>

      

It then proceeds to function as if all constraints worked with the intended functionality.

Here is a screenshot of my constraints for clarity:

Constraints Image

0


source to share


1 answer


I figure out that you are using a UITableView and creating a custom cell.
Subclass UITableViewCell, assign this class to your custom cell and rewrite awakeFromNib

like this:



- (void)awakeFromNib {
    [super awakeFromNib];
    self.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}

      

+1


source







All Articles