0

I'm trying to set a constraint in Auto Layout.

This:

self.myHeightConstraint = 0.0f;

gives me this error:

Assigning to 'NSLayoutConstraint *' from incompatible type 'float'

Setting it to 0 gives no errors but I'm not sure if that's doing what I want it to do. Basically I want to set the height of an item in the View to 0.

Looking at the docs I see this on creating a Constraint:

+ (NSArray *)constraintsWithVisualFormat:(NSString *)format
                             options:(NSLayoutFormatOptions)opts
                             metrics:(NSDictionary *)metrics
                               views:(NSDictionary *)views

but not sure how I'd use it.

1 Answer 1

1

You need to set constant for your height constraint to zero, but not the constraint itself.

The error exactly means that you try to assign float value to the constraint object.

Try

self.myHeightConstraint.constant = 0.0f;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.