ios – 在UITableview部分获取最后一个单元格

我在UITableView中有一个有多行的部分.我希望获得该部分的最后一行或最后一个单元格,以在其上添加披露指标.

我想使用的一种方式是:

NSIndexPath *lastCellIndexPath = [NSIndexPath indexPathForItem:[self.tableView numberOfRowsInSection:2]-1 inSection:2];

有什么其他最好的方式来获取单元格上的单元格或索引路径?

解决方法

NSInteger totalRow = [tableView numberOfRowsInSection:indexPath.section];//first get total rows in that section by current indexPath.
    if(indexPath.row == totalRow -1){
         //this is the last row in section.
    }

希望它有帮助.

我在tableView中这样做:willDisplayCell:forRowAtIndexPath:method

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

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...