0

I'm struggling to achieve below cell design in Swift. Not sure if it's even possible??

I have a multi-row table view with left and right cell. Both cells display text which vary in length. If text is really long and does not fit the cell, text on the left cell can be trimmed, but text in the right cell can never be trimmed or wrapped into 2 lines. In general, text in left cell is longer than text in the right cell therefore I have set up ratio about 70:30. However in some odd cases, text in the right cell is too long to fit into the cell without wrapping it into 2 lines (or getting trimmed).

Questions:

Wondering, if there is a way to change ratio between cells based on the text length of the right cell?

Can I give priority to left cell (to display as much text as possible), but if oddly long text needs to be displayed in the right cell, then switch priority to the right cell (to avoid text in right cell to be trimmed or wrapped to lines)?

Expected behaviour:

enter image description here

marika.daboja
  • 881
  • 13
  • 27
  • Tableview's can only have 1 cell per row, so its unclear what you mean by you have a tableview with 2 cells in each row. Its also not clear how you have achieved a "ratio of 70:30", is this with auto layout constraints? stackviews? are you actually using a collection view with a custom layout? It sounds more like you want the right to always have priority. Why would the left sometimes need priority (this is confusing)? Please edit your question, add your code or screenshots of your storyboard + constraints, and try to make it a bit clearer on what it is you need – Simon McLoughlin May 05 '22 at 11:00
  • It will help if you show some example text as well. Should the "left" labels be word-wrap multi-line labels? What do you want to happen if the text on the right is **really** long? See this: https://i.stack.imgur.com/VfHYS.png – DonMag May 05 '22 at 12:25
  • For the text, you can set the Content Hugging/compression priority: https://stackoverflow.com/questions/15850417/cocoa-autolayout-content-hugging-vs-content-compression-resistance-priority – Kush Bhavsar May 05 '22 at 16:24

0 Answers0