Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
Set Vertical compression resistance priority to 749 for UITableViewCell

enter image description hereI am working on making a table view cell that has the following constraint relationships.

    -----------------
    |                |
    |  ____________  |
    |  |          |  |
    |  |__________|  |
    |                |
    |  ____________  |
    |  |label.    |  |
    |  |__________|  |
    |                |
    |  ____________  |
    |  |          |  |
    |  |__________|  |
    |                |
    |  ____________  |
    |  |label.    |  |
    |  |__________|  |
    |________________|

The subviews are as follows: (view, label, view, label). I want the cell to dynamically resize with the two labels, for example, if the first label becomes taller, then the cell should become taller accordingly. If both labels become taller or shorter, the cell should resize accordingly. The two views should have a constant width and height.

If I start with a label I'm fine, a label and a view I'm fine, a label and a label, I'm fine, but if I have 2 labels and a view, as soon as I put the last constraint on the final label, auto-layout throws the error in storyboard (I don't have visible issues when running the app).

The problem is that I don't want to change the compression resistance because I don't want either of the labels to scrunch and I don't see why they would given the provided constraints.

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Modify last label's bottom constraint to a constant with relation "Greater Than or Equal"

Your code should look like

enter image description here enter image description here

Hope this works

over 4 years ago · Santiago Trujillo Denunciar

0

It seems like you have set the constraints properly, error on storyboards shows for even a tiny change in constraints like 0.5 pixels too. You can remove bottom constraints of last UILabel and reassign so that conflicting constraints can be rearranged. It will fix this problem.

To get the dynamic cell size:

  1. Set the number of lines for both UILabel to 0.

  2. Update relation of height constraints of both UILabel's from = to >=

  3. Apply the following table delegate method in your code

    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return UITableViewAutomaticDimension
    }
    

Use UIStackView to resolve the problem:

Rather than adding constraints to all the views, you can take all the view's in a stack view and just assign the top, bottom, leading and trailing constraint to stack view and keep table delegate method. I think this will be more appropriate way.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda