0
votes

I just want to display UIImageView with 150 px height and 100% width of content view in UITableViewCell. I just knew that I am not able to do this, because I clearly do not understand how Auto Layout works. First of all, I gave trailing and leading constraints, because image should have full width. Ok. AutoLayout still requires constraints, because it cannot solve its inner equation. Ok, then I gave 150 px height constraint. It still requires one additional constraint. And I really do not know which constraint should I give. Let it be vertical centering constraint, but in this case my image will not appear in its own full height. Let it be bottom constraint, but it also ruins my design as top constraint. So, what is the answer?

1
Can you elaborate " Let it be bottom constraint, but it also ruins my design as top constraint."? Try showing a screen shot of your design to help us better understand your issue. Thanks! - Miguel Tepale
Thanks for response. OK. I will elaborate. First of all I give trailing, leading constrains because my image should be show in full width. It is right. Then I give 150 px height constraint. It is also right. To solve equation, I need yet another constraint. Let it be top constraint. Then my cell cannot compute its height, because there is no bottom constraint. This kind of problem happens if I give just bottom constraint instead of top. So, how to solve such a problem? It seems easy design, but Auto Layout is really hard to understand. - neo
You would need to provide both top and bottom constraints in addition to the height constraint. That will let the cell be self-sizing. - Rudedog

1 Answers

0
votes

Here is something that I cooked up on Xcode. Hope this helps.

enter image description here