To find out the size of the text, you can use this method:
- (CGFloat)measureTextHeight:(NSString*)text fontName:(NSString*)fontName fontSize:(CGFloat)fontSize constrainedToSize:(CGSize)constrainedToSize { CGSize mTempSize = [text sizeWithFont:[UIFont fontWithName:fontName size:fontSize] constrainedToSize:constrainedToSize lineBreakMode:UILineBreakModeWordWrap]; return mTempSize.height; }
Then you can set the size cell:
-(CGFloat)tableView:(UITableVIew*)tableView heightForRowAtIndexPath(NSIndexPath *)indexPath;
source share