I have a tableview in which there is a uilabel inside the cell. label takes variable height on the basis of text.My codes are below
- (CGFloat)getLabelHeight:(UILabel*)label
{
  CGSize constraint = CGSizeMake(label.frame.size.width-10, 1000.0f);      
  CGSize size;
  NSStringDrawingContext *context = [[NSStringDrawingContext alloc] init];
  CGSize boundingBox = [label.text boundingRectWithSize:constraint
                                              options:NSStringDrawingUsesLineFragmentOrigin
                                           attributes:@{NSFontAttributeName:label.font}
                                              context:context].size;
  size = CGSizeMake(ceil(boundingBox.width), ceil(boundingBox.height));
  return size.height;
}
but setting constraint is difficult one. AnyOne knows the easiest way to calculate the height of cell dynamically and correct way of setting constraint.