Getting error when I add constraints

56 views Asked by At

I have a static UITableView with a UICollectionView and a UILabel that I added constraints programmatically to. Here is the code:

[_labelToChange setTranslatesAutoresizingMaskIntoConstraints:NO];
[_datesCollectionView setTranslatesAutoresizingMaskIntoConstraints:NO];

[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[_labelToChange(30)]-0-[_datesCollectionView]-0-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_labelToChange, _datesCollectionView)]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[_labelToChange]-0-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_labelToChange)]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[_datesCollectionView]-0-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_datesCollectionView)]];

When I do that, I get the following error:

2015-06-05 12:52:14.102 myApp[2373:44139] 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:0x7fa2e1d80470 V:[DIDatepicker:0x7fa2e1d7fd10]-(0)-|   (Names: '|':UITableViewCellContentView:0x7fa2e1d7f6d0 )>",
    "<NSLayoutConstraint:0x7fa2e1d80510 V:|-(0)-[DIDatepicker:0x7fa2e1d7fd10]   (Names: '|':UITableViewCellContentView:0x7fa2e1d7f6d0 )>",
    "<NSLayoutConstraint:0x7fa2e1da9740 V:|-(0)-[UILabel:0x7fa2e1da8970]   (Names: '|':DIDatepicker:0x7fa2e1d7fd10 )>",
    "<NSLayoutConstraint:0x7fa2e1da9990 V:[UILabel:0x7fa2e1da8970]-(0)-[UICollectionView:0x7fa2e20f8e00]>",
    "<NSLayoutConstraint:0x7fa2e1da9a10 V:[UICollectionView:0x7fa2e20f8e00(85)]>",
    "<NSLayoutConstraint:0x7fa2e1da9a60 V:[UICollectionView:0x7fa2e20f8e00]-(0)-|   (Names: '|':DIDatepicker:0x7fa2e1d7fd10 )>",
    "<NSLayoutConstraint:0x7fa2e1da4a50 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fa2e1d7f6d0(0)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fa2e1da9990 V:[UILabel:0x7fa2e1da8970]-(0)-[UICollectionView:0x7fa2e20f8e00]>
0

There are 0 answers