swift UITableView cell自适应高度
swift UITableView cell自适应高度
ios8支持:
1.
override func viewDidLoad() { super.viewDidLoad() self.tableView.estimatedRowHeight = 100 self.tableView.rowHeight = UITableViewAutomaticDimension }
2.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { ...... cell.textLabel?.numberOfLines = 0 cell.textLabel?.preferredMaxLayoutWidth = CGRectGetWidth(tableView.bounds) }
3.
func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { return UITableViewAutomaticDimension }
- 上一篇 »父容器内子容器浮动的高度自适应问题 _ CSS_HTML
- 下一篇 »css3让元素自适应高度