title: Dynamic cell height iOS
body: <p>I'm trying to dynamically recalculate the height of the cell that contain <code>UITextView</code>. The height of the cell depends on the height UITextView.</p>
  
  <p>The source code below recalculate height for each cell in table. This is the some text from <code>NSDictionary</code>. After all heights has recalculated I reload my table view with new height that contain in array heightCells;</p>
  
  <pre><code>UITextView *tempTextView = [[UITextView alloc] init];
  UIFont *font = [UIFont fontWithName:@"Helvetica" size:16.0];
  [tempTextView setFrame:CGRectMake(10, 63, 300, 9999)];
  [tempTextView setFont:font];
  NSString *str =  [d valueForKey:@"definition"]; // set long text
  tempTextView.text = str;
  CGRect frame = tempTextView.frame;
  frame.size.height = tempTextView.contentSize.height + 20.0;
  tempTextView.frame = frame;
  [tempTextView sizeToFit];
  int height = tempTextView.frame.size.height + 150.0; // set padding 150.0 px
  [heightCells addObject:[NSNumber numberWithFloat:height]];
  </code></pre>
  
  <p><code>UITableView</code> method:</p>
  
  <pre><code>- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
      return [[heightCells objectAtIndex:indexPath.row] floatValue];
  }
  </code></pre>
  
  <p>On not retina display everything work good and the height recalculated correct, but on retina display I have problem with recalculation. I know that the retina and not retina have one 320x480 points view and it should not affect for recalculation. But in my case this is appear.</p>
  
  <p>Please see screenshot below. As you can see on screenshot the bottom padding after share button a different for retina and not retina display. And I don't know which kind this problem.</p>
  
  <p><img src="https://i.stack.imgur.com/PsGaz.png" alt="retina"> </p>
  
  <p><img src="https://i.stack.imgur.com/6MI68.png" alt="not retina"></p>
  
  <p>Thanks for help!</p>