Where does the indexPath of dequeueReusableCellWithIdentifier:forIndexPath: get used?

后端 未结 4 1234
慢半拍i
慢半拍i 2020-12-08 00:31

Apple\'s documentation says of the indexPath parameter:

The index path specifying the location of the cell. The data source receives this

4条回答
  •  庸人自扰
    2020-12-08 01:15

    I always thought that UIKit would round the corners of the top and bottom cells in a grouped table view when the UITableViewDelegate method:

    - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

    is called. However, knowing the index path isn't much use unless the cell also knows how many rows are in the same section so it can work out if it's the last cell or not.

    I assume that the addition of the index path to the method dequeueReusableCellWithIdentifier: is to improve performance perhaps as @jrturton suggested with different reuse pools or simply to determine the position of a cell in grouped sections.

    As far as I can remember from the WWDC videos, there were a few additional methods added in iOS 6 to support reordering, insertion and deletion of cells so perhaps this also comes into factor here?

提交回复
热议问题