title: ios - can't get the UITableView cell height to be proportional to the amount of text
body: <p>I am trying to get the UITableView cells to fit the text.  So far I have something like this:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
      UILabel *label = nil;
  
      UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault)
              reuseIdentifier:@"business"];
  
      NSString *comment = [[items_array objectAtIndex:[indexPath row]] objectForKey:(@"comment")];
  
  cell.textLabel.numberOfLines = 0;
          cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
  
          CGSize constraint = CGSizeMake(320 - (10 * 2), 20000.0f);
  
          CGSize size = [comment sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
  
  
          label = [[UILabel alloc] initWithFrame:CGRectZero];
  
          [label setText:comment];
          [label setFrame:CGRectMake(10, 10, 320 - (10 * 2), MAX(size.height, 44.0f))];
  
          cell.textLabel.text = comment;  
      }
  </code></pre>
  
  <p>I also have this function</p>
  
  <pre><code>- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
  {    
      NSString *comment = [[items_array objectAtIndex:[indexPath row]] objectForKey:(@"comment")];
  
      CGSize constraint = CGSizeMake(320 - (10 * 2), 20000.0f);
  
      CGSize size = [comment sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
  
      CGFloat height = MAX(size.height, 44.0f);
  
      return height + (10 * 2);
  }
  </code></pre>
  
  <p>But it isn't allocating the right amount of height to the cells of the UITableViews. I think I am making some mistakes with how/where I assign the label and the text of the cells.</p>
  
  <p>Please help me understand how it should be.</p>
  
  <p>Thanks!</p>