Getting error while adding constraint

I am trying to set a limit on 2 viewsso that they touch each other as follows:

enter image description here

I tried to set the restrictions programmatically:

[self addConstraint:[NSLayoutConstraint constraintsWithVisualFormat:@"[_firstView][_secondView]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_firstView, _secondView)]];

But I get the following warning:

Incompatible pointer types sending 'NSArray *' to an NSLayoutConstraint type parameter

What am I doing wrong?

+4
source share
1 answer

The method addConstraint:expects one constraint, but constraintsWithVisualFormat:returns NSArrayfrom zero or more constraints.

Try adding s.

[self addConstraints:/*your NSLayoutConstraint constraintsWithVisualFormat: call */];

Apple . , constraintsWithVisualFormat - , addConstraint: - ( addConstraints: - ). .

+2

All Articles