views:

1501

answers:

4

UIScrollViewDelegate has got two delegate methods scrollViewDidScroll: and scrollViewDidEndScrollingAnimation: but neither of these tell you when scrolling has completed. scrollViewDidScroll only notifies you that the scroll view did scroll not that it has finished scrolling.

The other method scrollViewDidEndScrollingAnimation only seems to fire if you programmatically move the scroll view not if the user scrolls.

Does anyone know of scheme to detect when a scroll view has completed scrolling?

+3  A: 

Look at the UIScrollViewDelegate docs here:

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIScrollViewDelegate_Protocol/Reference/UIScrollViewDelegate.html

The method you're looking for is: scrollViewDidEndDecelerating:

Suvesh Pratapa
+4  A: 

I think scrollViewDidEndDecelerating is the one you want. Its UIScrollViewDelegates optional method:

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

Tells the delegate that the scroll view has ended decelerating the scrolling movement.

UIScrollViewDelegate documentation

texmex5
Er, I gave the same answer. :)
Suvesh Pratapa
Doh. Somewhat cryptically named but its exactly what I was looking for. Should have read the documentation better. Its been a long day...
Michael Gaylord
+1  A: 

Yes apple are crazy... I dont understand a lot of the inconsistently in the start/end style calls out of the sdk.. the 320 implementations are so mucbh better.. here is a patch to get consistent start/ends of on the scrolls.

add the lines;

-(void)scrollViewDidScroll:(UIScrollView *)sender 
{   
[NSObject cancelPreviousPerformRequestsWithTarget:self];
    //enshore that the end of scroll is fired because apple are twats...
    [self performSelector:@selector(scrollViewDidEndScrollingAnimation:) withObject:nil afterDelay:0.3]; 

...
}

-(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{
    [NSObject cancelPreviousPerformRequestsWithTarget:self];
...
}
Ashley Smart
A: 

thanx that works!

wassx