沒有可被用於檢測的UIScrollViewDelegate
的方法(或更好地說'預測')當滾動真的完成時:
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>)
of UIScrollViewDelegate
它可以用於檢測(或更好地說'預測')滾動時已經完成。
在我的情況我與水平滾動用它作爲以下(在夫特3):
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
perform(#selector(self.actionOnFinishedScrolling), with: nil, afterDelay: Double(velocity.x))
}
func actionOnFinishedScrolling() {
print("scrolling is finished")
// do what you need
}
也看,如果你想通過程序滾動後,檢測成品滾動:http://stackoverflow.com/questions/2358046/is-it-possible-to-be-notified-when-a-uitableview-完成滾動 – Trevor 2011-07-07 02:53:36