2017-07-13 41 views
0

我有一個tableView,並在每個UITableViewCell(調用此parentCell),我有另一個tableView有單元格(調用此childCell)。我正在使用UITableViewAutomaticDimension動態調整兩個單元格高度。我可以通過這種方式成功調整childCell的高度,但是,我無法將UITableViewAutomaticDimension應用於parentCell,因爲在調用heightForRow時,childCell的高度尚未估計。動態調整其中的tableView的單元格(iOS)

是否可以使用UITableViewAutomaticDimension來估計父級單元格的高度,這將是所有childCell高度加在一起的高度?或者我將不得不手動執行此操作?

//in ViewDidLoad 
parentTableView.rowHeight = UITableViewAutomaticDimension 

//in ParentCell's tableView's cell for row 
cell.childTableView.rowHeight = UITableViewAutomaticDimension 

func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat { 
    return UITableViewAutomaticDimension 
} 

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { 
    return UITableViewAutomaticDimension 
} 

回答

0

要做到這一點的唯一方法是使用部分,而不是放置在單元格內的tableview。

相關問題