The cell of tableView is added to calculate the height of the cell and call the proxy method, which is returned to the view controller.
When the server returns the data source, refresh the tableView.
However, the indexPaht of cellForRowIndexPath executed at this time starts from the fourth line,
The first few are skipped,
I tried to write the height of the cell as a fixed value,
The result is that the number of cells is normal.
What is the problem?
It should be that the height calculation is lagging.
Then requestThe display order of tableView is roughly:
Request
sectionNumber
andnumberForSection
to get the total number of sections and cells.sectionNumber
和numberForSection
获取一共有多少个section和cell。请求
heightForRow:atIndexPath
获取即将显示在界面上的 cell 的高度。然后请求
cellForRow
获取这个 cell 的实例。然后设置 cell 的高度等,layout 之后调用
willDisplay
RequestheightForRow:atIndexPath
to get the height of the cell that will be displayed on the interface.cellForRow
to get an instance of this cell.Then set the height of the cell, etc., and then call callback methods such as
willDisplay
after layout, and then display it on the interface.So when you refresh the tableView, the processing of the height part should be to first calculate the cell height according to the data source instead of letting the cell instance calculate it and then call back to the controller. Of course, you can also calculate in the cell. For example, there is a class method in the cell, which is calculated based on the incoming cell data, and the controller actively calls this method. The approximate code is as follows:
In the delegate implementation class of controller or tableView:
🎜MyTableViewCell:🎜