My problem is almost similar to this 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
+(CGSize)CommentSize:(NSString*)comment {
return [comment sizeWithFont:[UIFont boldSystemFontOfSize:messageTextSize] constrainedToSize:CGSizeMake(265, CGFLOAT_MAX) lineBreakMode:UILineBreakModeWordWrap];
}
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.
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
+(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;
}
how can i calculate the height. please help guys.
Found another link related to this issue https://github.com/mattt/TTTAttributedLabel/issues/82. Tried to implement the solution as suggested by mooshee. but couldn't solve the issue. can any one suggest how can i solve this.
Solution
A small edit to the second code snippet above solved the issue - Change the UILabel to TTTAttributelabel the height calculated using TTT and UIlabel are different.
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.
Thank you.