title: UITableViewCell with dynamic height iOS
body: <p>I have implemented TableView with CustomCell in my app,</p>
  
  <p>I want dynamic height of my <code>UITableViewCell</code> according to text length in <code>UITableViewCell</code>,</p>
  
  <p>here is the snapshot of <code>Customcell</code></p>
  
  <p><img src="https://i.imgur.com/RSGyL7c.png" alt="">:
  and here is the snapshot of my <code>UITableView</code>
  <img src="https://i.imgur.com/oPHLmL7.png" alt="">:
  code snippet for <code>heightForRowAtIndexPath</code></p>
  
  <pre><code>#define FONT_SIZE 14.0f
  #define CELL_CONTENT_WIDTH 320.0f
  #define CELL_CONTENT_MARGIN 10.0f
  
  - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
  {
      NSString *text = [DescArr objectAtIndex:[indexPath row]];
      CGSize constraint = CGSizeMake(CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), 20000.0f);
      CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:FONT_SIZE] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
      CGFloat height = MAX(size.height, 100.0);
      return height; 
  }
  </code></pre>
  
  <p>As you can see in the 2nd image, height for cell is fixed, it doesn't change with it's text (content) size.</p>
  
  <p>Where am I making mistake? How can I make a a label or a cell to update its size according to its contents/text?</p>