I'm currently trying to make a self sizing tableview (where the cells autosize to fit their inner view's autolayout).
One of the cells has a tableview in it. The idea is that the cell should be the size of the contentSize.height of the tableview.
I subclassed UITableView to accomplish this, and when the tableview loads, it looks great. However, this error gets spit out:
[Assert] UITableView internal inconsistency: _visibleRows and _visibleCells must be of same length. _visibleRows: {0, 4}; _visibleCells.count: 8, _visibleCells:
Additionally, when I try to scroll the tableview after this error there is very strange behavior and the tableview starts an infinite loop of layoutsubviews.
Any idea what this error means? I haven't been able to find anything substantial referencing this error on the internet. Thanks in advance!
1 Answers
Answers 1
If your view hierarchy of UITableView is something like this .
- UITableView
- UITableViewCells --- One cell has UITableView Follow this step to resize
1.Use tableview delegate method
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { tableView.estimatedRowHeight = 80.0 let modal = arrData[indexPath.row] if modal.isTableViewCell { let calculateTableViewHeight = modal.arrInnerTableViewData.count * inner_cell_height return calculateTableViewHeight } return UITableViewAutomaticDimension }
2.Disable the scroll of Inner tableView
0 comments:
Post a Comment