Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift UIWebView detect scroll

I have a UIWebView where I'm rendering a PDF. I need a method that hide the GUI if the pdf is not at the beginning of the page and show it again if the WebView hit the top. How can I check this?

like image 483
Alessandro Zago Avatar asked Dec 24 '22 02:12

Alessandro Zago


1 Answers

You can use scrollViewDelegate method scrollViewDidScroll for that like this way.

func scrollViewDidScroll(scrollView: UIScrollView) {

    if (scrollView.contentOffset.y == 0) {
        //Do what you want.
    }
}

Note: Don't forgot to set scrollView delegate of webView like this self.webView.scrollView.delegate = self

like image 167
Nirav D Avatar answered Jan 14 '23 07:01

Nirav D