Search code examples
iosxcodecocoauiwebviewuiwebviewdelegate

UIWebView bouncing callback


Is there a way for capturing a callback when the loaded web page in UIWebView is bouncing because user tried to scrolled to far?

i.e. user scrolls to the top of the webpage and he tries to scroll further, then bounce occurs. I want to capture such event in code.


Solution

  • You could obtain a reference to your webview's "scrollView" property, which is a UIScrollView instance, then check the contentOffset to see if it's negative. The problem is that in order to hook up to the scrollView's delegate method - (void)scrollViewDidScroll:(UIScrollView *)scrollView , you'll need to subclass UIWebView and set your subclass as the scrollView's delegate (scrollView is a readonly property of UIWebView). This is a bit tricky but it should get you to where you need.

    This question could also help you.