Reputation: 2405
I have a problem with using constraints. I want to put two UIViews
next to each other in a UITableViewCell
. It should look like this:
But after I add the suggested constraints, or when I add them manually, the cell always looks like this:
Why is it like that? The width of both UIViews
should be flexible depending on the width of the screen.
Can someone help me? Which constraints are missing?
Thanks!
Upvotes: 2
Views: 1934
Reputation: 96
I think the main thing you need is to add an "Equal Width" constraint between the two views. If you are using Interface Builder, press CTRL and drag one view to the other, a menu will appear and select "Equal Widths".
After that, you just need to pin your views borders to the Cell borders (except right border of left view to left border of right view)
Picture showing pin constraints
https://i.sstatic.net/lhpVk.png
Upvotes: 3
Reputation: 3393
do not use suggested constraints, clear all constraints of both view. Add constrains using "pin" 2nd option from left side(autolayout) for left side view add constraints 1) from left 2) from top 3) height 4) width
for right side view add constraints 1) from right 2) from top 3) height 4) width
Upvotes: 0