Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 10: NSInvalidLayoutConstraintException: Constraint improperly relates anchors of incompatible types

After updating to iOS 10 Im getting this error a bunch on one of my apps

NSInvalidLayoutConstraintException: Constraint improperly relates anchors of incompatible types:

<NSLayoutConstraint:0x170495270 UIView:0x1010e1d90.top == AppName.OtherView:0x1010dc6f0.centerX (active)>

I've never had an issue using a constraint like this before and I'm only getting it on my iOS 10 devices. Any ideas?

like image 845
Unome Avatar asked Sep 16 '16 13:09

Unome


1 Answers

You perhaps are doing something like this:

NSLayoutConstraint(item: viewA, attribute:
                .leading , relatedBy: .equal, toItem: parentView, attribute: .top, multiplier: 1.0, constant: 20)

So you do not stitch the correct anchors together like .leading and .top. In this case it must be .leading and .leading.

Interestingly this wasn't a problem with iOS9.

like image 138
netshark1000 Avatar answered Oct 08 '22 20:10

netshark1000