Nic Hubbard Nic Hubbard - 8 months ago 38
iOS Question

Don't let UILabel overlap another label in UITableViewCell

I have a custom

that has a titleLabel on the left, and a detail label on the right, similar to the
Right Detail
cell type.

enter image description here

Current neither
has a set width, which is what I want. However the
sometimes is very long and overlaps the detail label on the right.

How can I give a margin between the two labels, ONLY if the
is too long and will overlap?


The thing what you can do, is set minimum space between them by putting relation GraterThenOrEqual for example at 10 pixels. Or there is a dodgy way to it by playing with priority with constraints. You may set priority of constraint between as 750.

In the interface builder you have to set space between the labels, and then select manually this constraint, then you will see the menuenter image description here

called Relation, just choose there GraterOrEqual