0

Here are my attempts, cell is an instance of my prototype cell custom class derived from UITableViewCell. commentLabel is my IBOutlet to a UITextView, inside of the custom class. Scrolling in the UITextView is disabled.

Attempt 1:

cell.commentLabel.frame = CGRectMake(cell.commentLabel.frame.origin.x, cell.commentLabel.frame.origin.y, cell.commentLabel.frame.width, 500)

Attempt 2:

cell.commentLabel.frame.size.height = 500

Additional info (maybe unnecessary and irrelevant):

func tableView(tableView: UITableView!, heightForRowAtIndexPath indexPath: NSIndexPath!) -> CGFloat {
    return UITableViewAutomaticDimension;
}
User
  • 23,729
  • 38
  • 124
  • 207
  • 2
    Are you using AutoLayout? If so, adjusting the .frame property will do nothing, you need to update constraint constant instead. – Bek Sep 29 '14 at 17:57
  • Yes, I'm using AutoLayout to pin 3 of the sides of the UITextView. I didn't set the bottom constraint, because that's what I want to set manually. So where do I go from here? How do I access the constraints via code? – User Sep 29 '14 at 18:21
  • I've checked `cell.commentLabel.constraints()` and its contents are empty. – User Sep 29 '14 at 18:51
  • I posted an answer for you that I hope helps. – Bek Sep 29 '14 at 19:16
  • possible duplicate of [Using Auto Layout in UITableView for dynamic cell layouts & variable row heights](http://stackoverflow.com/questions/18746929/using-auto-layout-in-uitableview-for-dynamic-cell-layouts-variable-row-heights) – memmons Sep 29 '14 at 19:38
  • I've read that many times, but thats about TableView, not TextView. Thanks for trying to interrupt my question though. – User Sep 29 '14 at 19:40
  • @MichaelG.Emmons I also used some of that code from that link in the question, incase you skipped over that... – User Sep 29 '14 at 19:48

1 Answers1

-1

First, create an IBOutlet reference to your height constraint so that you can reference it from code. I've called mine 'heightConstraint'.

Then:

heightConstraint.constant = 500; [cell layoutIfNeeded]; //you many or may not need this li

Bek
  • 2,206
  • 20
  • 35
  • Error: `"heightConstraint" cannot have a prototype object as its destination.` – User Sep 29 '14 at 19:31
  • Why don't you add more information to your post about your auto layout constraints instead of downvoting and being sarcastic to people trying to help you. – Bek Sep 29 '14 at 19:42
  • That wasn't me that downvoted and I can prove that by downvoting again if you'd like me to...? Could it be possible someone else must think your answer is bad? – User Sep 29 '14 at 19:49