Detect the current top cell in a UITableView after scrolling

前端 未结 4 874
迷失自我
迷失自我 2020-12-04 17:01

a simple question but I don\'t seem to have the right terminology to search Stackoverflow by it.

I have a UITableView with no sections, the user can scroll up and do

4条回答
  •  无人及你
    2020-12-04 17:12

    In Swift 4:

    func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
        let firstVisibleIndexPath = self.tableview.indexPathsForVisibleRows?[0]
        print("top visible cell section  is \([firstVisibleIndexPath!.section])")
    }
    

提交回复
热议问题