设置行高之后,怎么又在UITableViewCell里面计算高度的时候计算准确 计算高度我是这样计算的 [content sizeWithFont:XYXYSYSTEMMedium_FONT(14) constrainedToSize:size lineBreakMode:UILineBreakModeWordWrap];
的确deprecated,但是还能用的。虽然警告
注意啊,我想设置的是UILable的行高啊。。。不是CELL的高度。。。 UILable的行高做好了,再去算CELL的高度
貌似这个可以吧
+ (CGFloat)heightOfCellWithIngredientLine:(NSString *)ingredientLine
withSuperviewWidth:(CGFloat)superviewWidth {
CGFloat labelWidth = superviewWidth - 30.0f;
// use the known label width with a maximum height of 100 points
CGSize labelContraints = CGSizeMake(labelWidth, 100.0f);
NSStringDrawingContext *context = [[NSStringDrawingContext alloc] init];
CGRect labelRect = [ingredientLine boundingRectWithSize:labelContraints
options:NSStringDrawingUsesLineFragmentOrigin
attributes:nil
context:context];
// return the calculated required height of the cell considering the label
return labelRect.size.height;
}