My code is below, as well as the image of my app. Basically I want to add a constraint in the viewDidLoad
method for this view controller to align the two labels so they start at the same x position. For whatever reason, I'm getting this warning, though:
Incompatible pointer to integer conversion sending 'UIView *' to parameter of type 'NSLayoutRelation' (aka 'enum NSLayoutRelation');
And when I run the app I get the following error:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]: Unknown layout attribute'
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self.carMakeLabel attribute:NSLayoutRelationEqual relatedBy:self.view toItem:self.carModelLabel attribute:NSLayoutAttributeLeading multiplier:1.0 constant:0];
[self.view addConstraint:constraint];
Try:
Make sure self.carModelLabel and self.carMakeLabel are both in the view hierarchy of self.view.
The signature of the method is
and you used
The data type sent to attribute is of relationship type:NSLayoutRelationEqual
Your first attribute and relatedBy arguments are switched I think.
You may have to correct that