iOS tableview how can I check if it is scrolling up or down

前端 未结 3 971
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-13 20:20

I am learning how to work with TableViews and I am wondering how can I figure out if the tableView is scrolling up or down ? I been trying various things such as this but it

3条回答
  •  不知归路
    2020-12-13 20:32

    You can implement scrollViewWillEndDragging method:

    func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer) {
    
    
        if targetContentOffset.pointee.y < scrollView.contentOffset.y {
            // it's going up
        } else {
            // it's going down
        }
    
    }
    

提交回复
热议问题