Search code examples
iosuiscrollviewuiscrollviewdelegate

UIScrollView bounce end event


Maybe I made a wrong description for what I want and hence haven't hit any answer, if that's the case please kindly provide a link with solution.

what I want is: I have scrollview, alwaysBounceVertical is set to true. So when the user drags down after the scrollview has already reached top, the scrollview should bounce. More specific: the view moves down as the user drags, and the moment the user releases his finger the scrollview bounces back.

The event I want to catch is the one that the scrollview finishes bouncing back. I want to apply an animation after this point. So could anyone tell me how should I modify which method in UIScrollViewDelegate to catch that event?


Solution

  • you can just use UIscrollView Delegate methods Apple Documentation and this an example

     - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    
        if(!decelerate){
         // Do something 
        }
    
    }
    
    - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
       // Do something 
    }
    

    for your problem you can apply your behaviour on scrollViewDidEndDragging