Search code examples
iphoneuiscrollviewuiscrollviewdelegate

How can I test if the scroll view is bouncing?


How can I test if the scroll view is bouncing? Is there a notification or something when the bounce ends?


Solution

  • Yes... check out the UIScrollViewDelegate spec, implement the methods including the two below, and set your UIScrollView's delegate accordingly:

    // User stops dragging the table view.
    
    - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView
        willDecelerate:(BOOL)decelerate;
    
    // Control slows to a halt after the user drags it
    
    - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;
    

    You will probably be most interested in scrollViewDidEndDecelerating. These also work in UITableView which is where I originally found them (UITableView inherits from UIScrollView).