UIScrollView scrollRectToVisible:animated: is there a way that a method can be called when animation ends
Yup use scrollViewDidEndScrollingAnimation
I do it like this because sometimes using the delegate isn't practical for me, like if i'm doing it in UIViewController transition:
[UIView animateWithDuration:0.3 animations:^{
[scrollView setContentOffset:CGPointMake(0, -scrollView.contentInset.top) animated:NO];
} completion:^(BOOL finished) {
// This is called when it's complete
}];
Implement UIScrollViewDelegate delegate methods for your UIScrollView the following way:
Use scrollViewDidEndScrollingAnimation:
to detect when the scrolling animation concludes when you've initiated the scrolling by calling setContentOffset:animated:
or scrollRectToVisible:animated:
methods (with animated:YES).
If you want to monitor scroll view motion that's been initiated by touch gestures, use scrollViewDidEndDecelerating:
method, which is called when the scrolling movement comes to a halt.