title: height For Row At Index Path not correct display
body: <p>a boy of StackOverflow had given such help to set the height of the cells automatically based on the content of the label ...</p>
  
  <p>I have implemented his method but when I scroll on tavleview, all the text in each cell overlaps and do not read anything ... Can you tell me what 's wrong with this code?</p>
  
  <p><img src="https://i.stack.imgur.com/V5dgi.png" alt="enter image description here"></p>
  
  <p>I had to change CGSize because I'm working on some code ios7 was deprecated for example:</p>
  
  <p> </p>
  
  <pre><code> CGSize size = [comment sizeWithFont: [UIFont systemFontOfSize: 14] constrainedToSize: lineBreakMode constraint: UILineBreakModeWordWrap];
  </code></pre>
  
  <p>Can you help me please?</p>
  
  <pre><code>- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
  {
  
      PFObject *object = [self objectAtIndexPath:indexPath];
      //Here you are getting the comment again.  This is necessary to determine how tall you need
      //the cell to be
      NSString *comment = [object objectForKey:(@"Testo")];
  
      // Again you are getting the constraints because you are going to us this size
      // to constrain the height of the cell just like you determined the size for the label.
      CGSize constraint = CGSizeMake(250 - (10 * 2), 10000.0f);
  
      // Again, determining the size that we will need for the label, because it will drive
      // the height of the cell
      UIFont *FONT = [UIFont systemFontOfSize:11];
  
       CGSize size = [comment boundingRectWithSize:constraint options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:FONT }context:nil].size;
  
      //  Finally, we can determine the height for the cell!
      CGFloat height = MAX(size.height, 44.0f);
  
      //  return the height, which is the height of the label plus some extra space to make
      //  it look good.
      return height + (10 * 2);
  }
  
  // Override to customize the look of a cell representing an object. The default is to display
  // a UITableViewCellStyleDefault style cell with the label being the first key in the object.
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {
      static NSString *CellIdentifier = @"Cell";
  
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      if (cell == nil) {
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
      }
      NSString *text = [object objectForKey:@"Testo"];
  
  
      CGSize constraint = CGSizeMake(250 - (10 * 2), 10000.0f);
  
      // This is determining the size that you will need for the label based on the comment
      // length and the contraint size
  
      UIFont *FONT = [UIFont systemFontOfSize:11];
  
      CGSize size = [text boundingRectWithSize:constraint options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:FONT }context:nil].size;
  
      //  Here you are creating your label and initializing it with the frame that you have
      //  determined by your size calculations above
      UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, MAX(size.height, 44.0f) + 20.0f)];
  
      // setting up the label properties
  
  
      label.numberOfLines = 0;
      label.lineBreakMode = NSLineBreakByWordWrapping;
      label.text = text;
      label.font = [UIFont systemFontOfSize:11];
  
      // adding the label view to the cell that you have created
      [cell.contentView addSubview:label];
  
      // Configure the cell
  
  
      return cell;
  }
  </code></pre>