http://tutuge.me/2015/08/08/autolayout-example-with-masonry2/ios
1.tableview:spa
自动计算 tableVIew 的 cell 的高度:orm
1. 建立 tableview 的时候:it
tableview.rowHeight = UITableViewAutomaticDimension;(自动获取 cell 的高度)io
2. 在heightForRowAtIndexPath: 方法中直接返回:UITableViewAutomaticDimension 便可. table
#define IOS8_TARGETsed
#ifdef IOS8_TARGETautolayout
// 这里作判断 大于 ios8的时候要作的事放在里面ios8
#endif方法
iOS 8以前的计算方式:
[cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height + 0.5;
[_templateCell.contentViewsystemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height + 0.5f