Tuesday, April 3, 2012

Useful for getting the Table View Cell height containing Text

-(CGFloat)labelHeightForText:(NSString *)text

{

   CGFloat constrainedSize = 231.0; //or any other size

   UIFont *font = [UIFont fontWithName:@"Helvetica" size:17.0];

   CGSize textSize = [text sizeWithFont:font 

                      constrainedToSize:CGSizeMake(constrainedSize, CGFLOAT_MAX)

                          lineBreakMode:UILineBreakModeWordWrap];

   return textSize.height;

}