0

I've been trying to figure this out for days. I can't get the constraints to work on this UITableViewCell. These are the constraints I have. enter image description here enter image description here enter image description here enter image description here but it comes out like this enter image description here The red is the cell background, cyan is the UIImageView background, green is the title Label, and blue is the percentage Label. How do I fix this? I want to make the row height the same as the image height in the UIImageView but the constraints are making the cell display it's subviews in a way I don't want. I want each cell layout to look exactly like the pictures of the cell I posted.

Community
  • 1
  • 1
Jeric
  • 315
  • 1
  • 3
  • 9
  • In the images we cannot read the constraints, what do you want to be fixed? It seems that you firstly reduce the row height. – Kerberos Jul 18 '18 at 18:46
  • @Kerberos I want to make the row height the same as the image height in the UIImageView but the constraints are making the cell display it's subviews in a way I don't want. I want each cell layout to look exactly like the pictures of the cell I posted. – Jeric Jul 18 '18 at 18:59
  • your images come from API or not?? location of your images – Bijender Singh Shekhawat Jul 18 '18 at 19:13

3 Answers3

1

Firstly, try to always set constraints to closest view. You have set the bottom constraint of title to the progressbar, for this reason you can see the green view behind the blue. Add the bottom constraint of title to percentage top.

Then, add the constraints of the image to top, bottom and leading, then add the aspect ratio constraint.

In your code add an height to the cell like how you do think it's better.

Kerberos
  • 4,036
  • 3
  • 36
  • 55
0

Make constraint like this

1- ImageView --> top , leading , bottom to contentView & trailing to title & width constraint

2- Title --> top to contentView , bottom to Percentage

3- Percentage --> leading , top to title , bottom to slider

4- Slider --> leading to Percentage & trailing ,bottom to contentView

5- Set vertical content compression resistance for Percentge to 1000

6- Dont't implement heightForRowAt and use automatic tableView cells settings

Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87
0

You're going to want to highlight both the image and the label that you want to equal the same height, click on the "Add New Constraints" button in the bottom right, and then click "Equal Heights".

Jet.B.Pope
  • 642
  • 1
  • 5
  • 25