Vlad Vlad - 1 year ago 71
iOS Question

What happens when attaching exactly the same NSLayoutConstraints to the same UIView multiple times?

The question says it all. Does it get ignored? Or does it just keep attaching the same constraint multiple times?

Also is there any performance issue if I do this?

I'm asking because the alternative seems to be keep reference to all constraints as they get attached and then later look them up to make this decision. It would be nice if I don't have to implement all this logic.

Answer Source

Yes, adding same(same NSLayoutConstraint object) constraints again, are ignored.

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download