views:

1060

answers:

2

I would like to modify the animation duration and attach a callback to be called when the animation finishes when calling scrollToRowAtIndexPath with animated:YES but I can't find a handle to its animation proxy or any other way to do it.

Anyone know if this is possible?

+4  A: 

in your TableView delegate, implement -scrollViewDidEndScrollingAnimation:. This will get called once the scroll animation has completed.

Ben Gottlieb
Fantastic, any idea how to change the duration?
Dave Verwer
That I don't think you can do. You could set up your own animation, I'm not sure but I believe that the contentOffset property is animatable.
Ben Gottlieb
A: 

Greetings. Following- up on the question above...

I am looking for a way to grab the scroll position after each time a user scrolls a table view. I came across the scrollViewDidEndScrollingAnimation, which I believe may do the trick. It appears to be a UIScrollViewDelegate method, however, and I have been unable to figure out how to have it called when using a Table View (which I think is what is suggested by Ben Gottlieb).

Any chance someone could help me understand how to make this work or point to sample code?

Many thanks.


2 hours later...

Not sure if the is the right way to do it, but I've got it working and thought I would post back here 1) in case others are searching on this and 2) in case there is a better way of doing this that others can point me toward.

Turned out to be quite simple. In the interface declaration, I added the UIScrollViewDelegate protocol like so:

@interface ListViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UIScrollViewDelegate> { ... }

Then added the appropriate delegate methods in the .m file like this:

- (void)scrollViewDidEndDragging:(UIScrollView *)sender willDecelerate:(BOOL)decelerate { do something; }

I was originally getting hung-up on only having a tableView defined and not something called a scollView, but I guess the delegate calls trickle down because tableView is a subclass of scrollView?

I've tried several of the methods in the ScrollViewDelegate Protocol, and it seems like most are being called with this (but not scrollViewDidEndScrollingAnimation?).