title: How to Calculate the height of text which contains emoji iphone
body: <p>My problem is almost similar to <a href="https://stackoverflow.com/questions/15965525/how-to-get-nsstring-size-when-nsstring-includes-emojis">this</a> setting size to fit  displays all the text in the label but it overlaps the other cells in table view as the height of the cell is different. to calculate the height I am currently using this method</p>
  
  <pre><code>+(CGSize)CommentSize:(NSString*)comment {
  
  return [comment sizeWithFont:[UIFont boldSystemFontOfSize:messageTextSize] constrainedToSize:CGSizeMake(265, CGFLOAT_MAX) lineBreakMode:UILineBreakModeWordWrap];
  }
  </code></pre>
  
  <p>It calculates the height of the text properly but the extra height(6 pix) that occupied by the emoji is not being added to the message height.</p>
  
  <p>I also tried to set the text to another label made it sizetofit and get the height and pass it like this but it gives the same height as the above constrained method</p>
  
  <pre><code>+(CGSize)CommentSize:(NSString*)comment {
  
      UILabel *reviews = [[UILabel alloc]initWithFrame:CGRectMake(14, 13,265,30)];//Set frame
      reviews.numberOfLines=0;
      reviews.lineBreakMode = UILineBreakModeWordWrap;
      reviews.font = [UIFont boldSystemFontOfSize:14];
      reviews.text = comment;
      [reviews sizeToFit];
  
      CGFloat reviewlblheight = reviews.frame.size.height;
  
      CGSize maxlblSize = CGSizeMake(265,reviewlblheight);
      return maxlblSize;
  
  }
  </code></pre>
  
  <p>how can i calculate the height. please help guys. </p>
  
  <p>Found another link related to this issue <a href="https://github.com/mattt/TTTAttributedLabel/issues/82" rel="nofollow noreferrer">https://github.com/mattt/TTTAttributedLabel/issues/82</a>. Tried to implement the solution as suggested by mooshee. but couldn't solve the issue. can any one suggest how can i solve this.</p>
  
  <p><strong>Solution</strong></p>
  
  <p>A small edit to the second code snippet above solved the issue - <strong>Change the UILabel to TTTAttributelabel</strong> the height calculated using TTT and UIlabel are different. </p>
  
  <p>Any one else who face the same issue can use the second code snippet. I am not sure whether it is correct approach are not but it solves the problem.</p>
  
  <p>Thank you.</p>