Maen
Maen

Reputation: 10698

Resize UITextView inside a UITableViewCell with iOS Autolayout

My Goal

I'm creating a custom UITableViewCell (MessageCell), and I'd wish to have my UITextView resizing both in width and height whenever the cell changes its size, while keeping some basic constraint like margins to the edges.

Note : I also change my cell's height in the heightForRowAtIndexPath method depending on the content which will be placed into UITextView.

What I tried

Here are all the constraints currently applied & the cell : enter image description here

I tried :

How it render now

enter image description here

So...

If someone has any clue or guideline to achieve my goal, I'd appreciate!

I might add, I'm totally new to Autolayout & constraints. My reference : Ray Wenderlich's awesomeness

Upvotes: 4

Views: 3242

Answers (1)

rdelmar
rdelmar

Reputation: 104082

You need to get rid of that height constraint that the text view has. Make sure you have constraints to something above and below the text view (usually the top and bottom of the cell), and then you should be able to delete that height constraint.

Upvotes: 3

Related Questions