Reputation: 5089
I have a simple custom UITableViewCell
that looks like this:
The UIImageView
is supposed to stay as tall as the cell, and at the same proportion while being on the far left. This works.
The title label is supposed to stay centered vertically, and x amount of pixels from the image. This works.
Finally, the 9.9 label is supposed to be centered vertically and x amount of pixels from the disclosure indicator on the right. This works.
The problem is, I'm trying to make the title label as wide as possible, while remaining x pixels from the image and the 9.9 label. I try to do this by setting constraints on the image (left padding) and 9.9 label (right padding), but then Xcode complains that the horizontal settings for the 9.9 label are ambiguous.
Can anyone help me give the title label a dynamic width without destroying the 9.9 label's constraint to the right?
Upvotes: 0
Views: 120
Reputation: 8014
Probably a bit late, but you have 2 labels which can grow or shrink. Since you have given the constraints no clues, the code can not decide if Title should grow or 9.9 should grow to fit the width of the screen.
You can adjust the horizontal hugging/compression of the Title so that it grows before the 9.9 label would. This means you can avoid using fixed widths.
Upvotes: 3
Reputation: 5909
I think it will work if you constraint the 9.9 label with a fixed width (assuming you know its size won't change).
so from the left:
x
pixelsx
pixelsx
pixelsHope this helps
Upvotes: 1