0
我想讓我的最後一個單元格獲取tableview中留下的所有剩餘空間。所以我寫了這段代碼:最後一個單元格必須佔用表格中剩餘的所有空間查看
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if indexPath.row == tableView.numberOfRows(inSection: 0) - 1 {
let sectionheight: CGRect = tableView.rect(forSection: 0)
let tableViewFrame: CGRect = tableView.frame
let height: CGFloat = tableViewFrame.size.height - (sectionheight.size.height - 100)
cell.frame.size.height = height
cell.layoutIfNeeded()
}
}
,並在heightForRow該小區我只返回一個像100
的問題是,計算出的高度是正確的值,但電池不更改。
如何確保細胞高度發生變化?