alex alex - 3 months ago 19
Swift Question

Swift UIWebView detect scroll

Hello to everyone 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?
Sorry for bad english, i'm italian.

Answer

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