tableviewcell 中使用autolayout自适应高度

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
[cell setNeedsUpdateConstraints];
[cell updateConstraintsIfNeeded];
  CGSize size = [self.prototypeCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
  return size.height+1;
}

  • Return the height of the cell remembering to add 1 point for the cell separator.
 cell 中要完全的根据控件之间的属性,可以计算出cell的高度,在使用时,自己可以在图纸上比划一下,根据已知的控件的约束能不能计算出一个cell的高度 

握不住的沙,干脆扬了它。
原文地址:https://www.cnblogs.com/zj901203/p/4277562.html