Guillermo Fuentes
Guillermo Fuentes

Reputation: 39

My multiline label in swift doesn't work, the phrase is all in one line out of size of the label

I have some labels inside of a custom cell but I want to make them multiline, and it doesn't matters if I select multiline in the storyboard or not, my string still in one line in the label and goes out of the sizes of the label. This is my storyboard: Storyboard and here is how my screen is viewed Screen

Maybe I have to write it in code but it doesn't work too, here is my custom cell code:

import UIKit

class Celda: UITableViewCell {



@IBOutlet weak var Titulo: UILabel!
@IBOutlet weak var Fecha: UILabel!
@IBOutlet weak var Precio: UILabel!
@IBOutlet weak var Descripcion: UILabel!

func setCelda(celda : Gastos){

    Titulo.text = celda.titulo
    Descripcion.text = celda.descripcion
    Fecha.text = celda.date
    Precio.text = String(celda.precio)
}

}

It's impossible that this class is the problem. Any solutions please?

Last update: Dynamic Cell

Upvotes: 1

Views: 1711

Answers (1)

Paul T.
Paul T.

Reputation: 5038

1) You can use Number Of Lines = 0, that will allow as many lines as text needs

2) I assume that you want the cell height to depend on the label height, in this case you can set in code or in Storyboard for table view: Height Dynamic (you need to set estimated height to any value, otherwise it will not work)

3) than in storyboard you set your cell's height to fit the label height and label bottom constraint should be == to bottom of the cell

Upvotes: 2

Related Questions