Detect the current top cell in a UITableView after scrolling

前端 未结 4 864
迷失自我
迷失自我 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:16

    This is the Swift 3+ code:

    override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
        let firstVisibleIndexPath = self.tableView.indexPathsForVisibleRows?[0]
        print("First visible cell section=\(firstVisibleIndexPath?.section), and row=\(firstVisibleIndexPath?.row)")
    }
    

提交回复
热议问题