I referenced this question: How to detect when a UIScrollView has finished scrolling
UITablewView is a subclass of UIScrollView, and my UITableView delegate does get the - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
message when I scroll the table by hand.
However, when I call - (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated
to scroll the table, I don't get the scrollViewDidEndDecelerating
message. I am calling the scrollRowToIndexPath...
method with animated:YES
.
Is this a bug/API limitation (on iPhone SDK 3.1.3) or am I missing another way to do this?
Just in case someone is still chasing this one, the Apple docs say the following under the scrollToRowAtIndexPath:atScrollPosition:animated:
documentation:
"Invoking this method does not cause the delegate to receive a scrollViewDidScroll: message, as is normal for programmatically-invoked user interface operations."
I had the same problem. But I solved it by doing this after programmatically scrolling to the specified row:
NSTimer *t = [NSTimer scheduledTimerWithTimeInterval: 0.6
target: self
selector:@selector(doneScrolling)
userInfo: nil repeats:NO];
In my case, I just wanted to highlight the row after it was scrolled to.
OR
If you want the code executed more immediatly and don't want to wait for .6 seconds, you might be able to loop to keep checking whether the row that you've scrolled to is visible yet. Use the visibleCells property on the UITableView. When it's visible, then you know it's done scrolling and you can execute your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With