Swift Cell 自适应高度 仅支持IOS8+:
1.
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.estimatedRowHeight=100
self.tableView.rowHeight= UITableViewAutomaticDimension
}
2.
//可省略 默认自动统计
func tableView(tableView: UITableView, cellForRowAtIndexPathindexPath: NSIndexPath) -> UITableViewCell {
cell.textLabel?.numberOfLines=0
cell.textLabel?.preferredMaxLayoutWidth= CGRectGetWidth(tableView.bounds)
}
3.
func tableView(tableView: UITableView, heightForRowAtIndexPathindexPath: NSIndexPath) -> CGFloat {
returnUITableViewAutomaticDimension
}