问题描述
我正在关注此
我预期的iOS 9:
任何建议都将受到赞赏!
更新
中的代码> viewDidLoad
:
tableView.registerNib(UINib.init(n ibName:SelfSizingCell,bundle:nil),forCellReuseIdentifier:cellIdentifier)
tableView.dataSource = self
tableView.delegate = self
tableView.estimatedRowHeight = 60.0
tableView.rowHeight = UITableViewAutomaticDimension
tableView.reloadData()
add返回单元格之前的cellForRowAtIndexPath方法中的代码。
cell.setNeedsUpdateConstraints()
cell.updateConstraintsIfNeeded()
I was following this tutorial to make self sizing cells.
I registered custom cell into table view and in the cell xib I gave every subview constraints manually. Please refer to the source code in GitHub
Arranging 3 labels vertically in one cell's content view worked fine in iOS 9 but not in iOS 8 (both tested in device and simulator).
In iOS 8 one cell does not have fitting height and not every label shows all it's full text.
iOS 8 not fitting:
iOS 9 as I expected:
Any advice would be appreciated!
Update
code in viewDidLoad
:
tableView.registerNib(UINib.init(nibName: "SelfSizingCell", bundle: nil), forCellReuseIdentifier: cellIdentifier)
tableView.dataSource = self
tableView.delegate = self
tableView.estimatedRowHeight = 60.0
tableView.rowHeight = UITableViewAutomaticDimension
tableView.reloadData()
add following code in "cellForRowAtIndexPath" method before return cell.
cell.setNeedsUpdateConstraints()
cell.updateConstraintsIfNeeded()
这篇关于UITableViewAutomaticDimension无法在iOS 8上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!