-3

I have a uitableview cell. I want it to expand and show a lot of text. I set it up with autolayout and constraints. It looks right, but when I run it only shows up to two lines. I don't understand. Can someone point me in the right direction? Thank you.

Here's a link to an image of the setup: https://docs.google.com/document/d/1V8jetMrVDK4ebaconz9PL0y3DnJUqXmPkfyhK-0Nhbc/edit?usp=sharing

djax1234
  • 3
  • 5

2 Answers2

1

From the 2014 WWDC, with iOS 8, if you

  1. Set up autolayout constraints relative to cell.contentView
  2. Use the estimatedRowHeight property
  3. Dont implement -[UITableView tableView:heightForRowAtIndexPath:]
  4. Dont use the rowHeight property

then you can take advantage of self-sizing cells that will expand automatically based on their content.

Check out WWDC '14 under "What's New in Table and Collection Views." You'll only need to watch the first 25 minutes or so.

Louis Tur
  • 1,303
  • 10
  • 16
0

Implement the following two TableView methods

-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return UITableViewAutomaticDimension;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewAutomaticDimension;
}

Working with Self-Sizing Table View Cells Here is a useful reference.