onkar onkar - 5 months ago 33
Swift Question

Add swipeGesture to webView and stop ZoomIn and ZoomOut

I need to add

swipeGesture
to my
UIWebView
, however I need to stop the ZoomIn and ZoomOut of that
UIWebView


/*Swipe is enabled and zoom as well*/
webViewPlayer.scalesPageToFit = true


When I am changing it to

webViewPlayer.scalesPageToFit = false
//zooming and swipe both disabled


Edit 1

I just want swipeGesture to
UIWebView
only without
ZoomIn
and
ZoomOut


I have tried adding
swipeGesture
to both
UIWebView
and
self.view

Answer

Try this...

Because UIWebView contains scrollview in it so you can use method below to check that scroll is on which direction.

This is an alternative way to check direction of Swipe because swipe gesture don't work on very well UIWebView.

Give scrollviewDelegate to UIWebView

    webView.scrollView.delegate = self

ScrollView Delegate

func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>)
{
    if velocity.x < 0
    {
        print("Going Left!")
    }
    else if velocity.x > 1
    {
        print("Going Right!")
    }
}