Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text in table view cell not wrapping to second line

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)!

like image 481
Marmelador Avatar asked Jul 11 '17 10:07

Marmelador


People also ask

Why is my text not wrapping in Excel?

Wrap text automatically On the Home tab, in the Alignment group, click Wrap Text. (On Excel for desktop, you can also select the cell, and then press Alt + H + W.) Notes: Data in the cell wraps to fit the column width, so if you change the column width, data wrapping adjusts automatically.

What automatically wraps text to the next line?

The correct answer is Word Wrap. Word Wrap is the tool used to wrap text to the next line as it reaches the right margin in MS Word. When the right margin is reached while typing, a word processor's Word Wrap feature will automatically force content to a new line.

How do you wrap text in Word?

Select Format and then under Arrange, select Wrap Text. Choose the wrapping option that you want to apply.

What is text wrapping in Excel?

Wrap text in a cell or group of cellsText inside the cell wraps to fit the column width. When you change the column width, text wrapping adjusts automatically. Note: If all wrapped text is not visible, it might be because the row is set to a specific height.


2 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
like image 180
Shubhdeep Bhattacharya Avatar answered Nov 09 '22 06:11

Shubhdeep Bhattacharya


For getting the lines without the dots, Do the following -

  1. Take the UILabel inside the cell, go to the attribute inspector.
  2. In the attribute inspector find lines and change it to 0.
  3. Then, change the line break to WordWrap

I think this will work.

like image 44
Vishnu Prasannan Avatar answered Nov 09 '22 06:11

Vishnu Prasannan