Resize UITextView inside UITableViewCell with iOS autoload

My goal

I am creating a custom UITableViewCell (MessageCell), and I would like my UITextView to resize both in width and in height when the cell resizes, while preserving some basic constraints similar to fields. >

Note. I also change the height of my cell in the heightForRowAtIndexPath method depending on the content that will be placed in the UITextView.

What i tried

Here are all the restrictions that apply and the cell: enter image description here

I tried:

  • With UILabel .
  • To fix Vertical Space from below, thinking that it will change the height to fit all restrictions.
  • To override Height with a custom constraint Height >= 43 (my initial height), but the purple-automatic Height is recreated again when I do this.
  • First find a solution on SO, but not find such a case (even if the height of the resizing UITextView with autostart seems to be a common problem).
  • Many combinations of different and random constraints until my fingers thicken.

How to do it now

enter image description here

So...

If anyone has any tips or recommendations to achieve my goal, I will be grateful!

I would add that I am completely unfamiliar with Autolayout and the limitations. My link: Amazing Ray Wenderley

+4
source share
1 answer

You need to get rid of the height limit that the textual representation has. Make sure you have restrictions on something above and below the text view (usually the top and bottom of the cell), and then you should be able to remove the height limit.

+3
source

All Articles