Search code examples
iosobjective-cui-design

UILabel writing over another UILabel when to long text


I stumbled on to a problem to which i am not sure how to fix.

enter image description here

As you can see here the Label where the name is supposed to be,(i get the name from a user input meaning its dynamic). If it is written to long, it just writes over the other labels.

Also in the storyboard the UILabels are not set to be longer than another label. Each label ends right before the other one starts.

FYI i have already used constraints to make them have the position that they should. Any suggestions?

EDIT1

Also the name label to the right(the last cell) there should be more text but it is not visible. As if it is continuing to write over the edge?

EDIT2

Here is an image showing the constraints i have on the label and some other useful info. enter image description here

EDIT3

Here is an image after i tried to remove the constraints and i even made the label so small but the results are still the same. The text is going all the way to the score label

enter image description here


Solution

  • Your constraint of the label width is set to 221, so its width will be 221 no matter what screen it is on. Thats why on simulator it behaves like this(different screen size than storyboard). Your constraints are wrong, thats why its overlapping, your label is bigger than its suppose to be.

    EDIT

    Set score label width constraint, set score label center horizontally and vertically in superview. Now right text label attach to this score label and superview, and left text label attach to this score label and time label, also set this time label width contraint so it doesnt change, its a small text and u know the size of it all the time, so you can keep it at width like 30. Now you are done, your text labels are adjusting their size according to screen.

    If its still not working, check your superview has set constraint to adjust to screen size, as well as tableview.