Text in table view cell not wrapping to second line

Viewed 5626

I have a cell which may have to display a long text. In this case it should wrap to a second line.

I have Lines set to 2 and Line Break set to Word Wrap in the attributes Inspector. The Interface Builder preview confirm that and behaves as expected/desired.

enter image description here

When building and running however the text is limited to one line and truncuates at the tail: enter image description here

Other changes in the attribute inspector seem to have no effect aswell (text alignment for example)!

6 Answers

If anyone is still having the problem.. Here's the solution for swift 4 Xcode 9 iOS 11

inside the cellForRowAt tableview function you just have to add a single line of code

cell?.textLabel?.numberOfLines = 0

The constraints might not have set properly for the UILabel. So, the UILabel will keep on expanding as the text increases.

  • Set the UILabel constraints with autolayout constraints or give a static width (or left and right properties).
  • Now in label attributes inspector set lines to 0
Related