I am trying to call a method after my scroll animation is complete. I have a Table View and I set the delegate in viewDidLoad like thisself.tableView.delegate = self
based on this , but that didn't help.
Basically, If a button is clicked, it scrolls up to a specific cell, lets call it the start cell, in the table view if the start cell is not visible. I'm using the scrollToRow method for the scrolling and animation
tableViewController.tableView.scrollToRow(at: IndexPath(row: techniqueNo, section: 0), at: UITableViewScrollPosition.top, animated: true)
Once this scroll animation is complete, I want to add an animation to the start cell. I tried adding this method from the scroll view delegate, but it isn't getting called
func scrollViewDidEndScrollingAnimation(scrollView: UIScrollView) {
print("animation Complete")
}
Any idea why this method is not getting called?
Note: This is different from UITableView is done scrolling because (1) this is swift and that answer is Objective-C, and (2) I have tried implementing the method from the delegate to check if the animation finished, but its not getting called and I need help figuring out why
Is this what you need?
Add these funcs to your table view controller...
Edit: forgot to include the scrollViewDidEndScrollingAnimation
...
override func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
scrollingFinish()
}
override func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
scrollingFinish()
}
override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
if !decelerate {
scrollingFinish()
}
}
func scrollingFinish() -> Void {
print("Scroll Finished!")
}