检测scrollToRow函数的结束

时间:2017-11-13 01:42:44

标签: swift3

如何在tableview中检测scrollToRow函数的结束?我试图实现scrollViewDidEndScrollingAnimation函数,但是当scrollToRow结束时它不会被调用。

2 个答案:

答案 0 :(得分:0)

您应该将代理添加到Scrollview:

override func viewDidLoad() 
{        
    super.viewDidLoad()  
    self.scrollview.delegate = self
}

答案 1 :(得分:0)

 func scrollViewDidScroll(_ scrollView: UIScrollView) {
    let  height = scrollView.frame.size.height
    let contentYoffset = scrollView.contentOffset.y
    let distanceFromBottom = scrollView.contentSize.height - contentYoffset
    if distanceFromBottom < height {
        print(" you reached end of the table")
    }
}