title: Discrepancy between sizeWithFont:constrainedToSize:lineBreakMode: and textView.contentSize.height
body: <p>I am using the method <code>[string sizeWithFont:constrainedToSize:lineBreakMode:]</code> to estimate the height of a <code>textView</code> that I am resizing. However, it seems to consistently return the incorrect size. To debug, I wrote the following code:</p>
  
  <pre><code>self.textView.font = [UIFont systemFontOfSize:14.0]; // It was this before, anyways
  NSLog(@"Real width: %lf %lf", self.textView.contentSize.width, self.textView.frame.size.width);
  NSLog(@"Real height: %lf", self.textView.contentSize.height);
  NSLog(@"Estimated width: %lf", kOTMessageCellTextWidth);
  NSLog(@"Estimated height: %lf", ([message.message sizeWithFont:[UIFont systemFontOfSize:14.0]
                                               constrainedToSize:CGSizeMake(kOTMessageCellTextWidth, CGFLOAT_MAX)
                                                   lineBreakMode:UILineBreakModeWordWrap].height));
  </code></pre>
  
  <p>However, the above code reveals that I am getting inconsistent results:</p>
  
  <blockquote>
    <p>Real width: 223.000000 223.000000<br />
    Real height: 52.000000<br />
    Estimated width: 223.000000<br />
    Estimated height: 36.000000<br />
    Real width: 223.000000 223.000000<br />
    Real height: 142.000000<br />
    Estimated width: 223.000000<br />
    Estimated height: 126.000000<br />
    Real width: 223.000000 223.000000<br />
    Real height: 142.000000<br />
    Estimated width: 223.000000<br />
    Estimated height: 126.000000<br /></p>
  </blockquote>
  
  <p>I noticed in <a href="https://stackoverflow.com/questions/3141399/calculate-the-height-of-a-uitextviews-text-with-sizewithfontconstrainedtosizel">this similar question</a> that (apparently) <code>textView</code> has some padding that constrains its actual width. The recommendation there was the decrease the width passed to <code>sizeWithFont:</code> by some number. The recommended number was 11.</p>
  
  <p>My question: is there any way to actually retrieve this value programmatically, or is there some documentation that I missed specifying this number? It seems like this number should be available and shouldn't have to be guess-and-checked, but I can't find a reliable way to identify it.</p>
  
  <p>Thanks in advance.</p>