Get last cell in a UITableview section

后端 未结 7 695
心在旅途
心在旅途 2021-01-17 10:17

I have a section in UITableView which has multiple rows. I wish to get the last row or the last cell of the section to add a disclosure indicator on it.

One way I am

7条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-17 10:42

    Swift version:

    let totalRows = tableView.numberOfRows(inSection: indexPath.section)
    //first get total rows in that section by current indexPath.
    if indexPath.row == totalRows - 1 {
        //this is the last row in section.
    }
    

提交回复
热议问题