0

So a small project I'm working on is ALMOST complete. Functionally, it's fine. But it revolves around a UITableView with several UI elements within the cell, including an image, 2 labels and a HorizontalStackView. And in several instances the label texts trail beyond the range of the label.

I'm sure I can use .sizeToFit() somewhere, but the only location I can think of is within cellForRowAt when setting up the cells and that doesn't seem to be working.

I'm also hoping to keep the constraints such that the text/label doesn't also bleed into the Horizontal Stack View (to the right of the labels) or backwards into the image (to the left of the labels).

Joey Nash
  • 35
  • 6
  • What actually issue you'r facing and what you have getting pls mention. For more clarification use image to describe your question with UI Images if required. – dahiya_boy Nov 04 '17 at 16:47
  • My issue: Within 2 UILabels (both held within a CustomCell of a UITableView) is text that is larger than the labels. I want to be able to resize them without breaking constraints (so that after resizing the labels do not intrude on other UI elements within the cell). – Joey Nash Nov 04 '17 at 16:51
  • Check this [answer](https://stackoverflow.com/questions/42416733/self-sizing-tableview-cells-based-on-two-subviews-height/42417325#42417325). If you have still any doubt then ask. – dahiya_boy Nov 04 '17 at 17:52
  • This one seems to be all about resizing the cell height to match elements, I'm worried about resizing the label itself. Forgive me if I missed something. – Joey Nash Nov 04 '17 at 19:30
  • I wish you provided some code showing us what you have done but I highly suspect that such an issue can be sorted using content hugging and compression resistance. – Sam Ngugi Nov 04 '17 at 21:45
  • @JoeyNash This the only thing that you have to do. – dahiya_boy Nov 05 '17 at 04:35

1 Answers1

0

You can use the horizontal and vertical compression resistance properties on you UI elements to give an element priority to grow over another. Can you add an image we may have a better understanding of the problem.

Luke
  • 26
  • 5